Materialized Views Part 2 - MVs in Rails


In Supercharge your app with materialized views, we discussed some of the benefits of using materialized views in a web application, and some of the situations in which a Materialized View may be a good choice.

My framework of choice is Rails. Rails' default ORM, ActiveRecord, is very good, but it does not provide any real integration for views, materialized or otherwise. This becomes an issue, as views can only be dropped and re-defined - not incrementally changed with add_column or the like - thereby requiring us as developers to manually ensure that we’re correctly defining the view each time we wish to update it.

Originally, this post was going to be a discussion of some of the ways of managing this complexity, but I have since discovered scenic, a gem by thoughtbot designed specifically for managing materialized views. I recommend you check it out for all of your view management needs.

Get Notified of New Posts

* indicates required