Rails on PostgreSQL: PGCon 2010 talk on Rails and PostgreSQL
Aug 03, 2010
A while back I posted a link to a talk by Gleb Arshinov that he gave at the SF PUG. This talk was on “PostgreSQL for high performance Rails apps”, and was full of fine suggestions from their experiences with their Rails apps. Gleb is back again, this time on May 21 2010 at PGCon where he and Alexander Dymo talked about PostgreSQL as a secret weapon for Rails apps. Some of the same ground is covered (use SQL DDL vs ActiveRecord
Lots of good stuff there, enjoy!create_table, etc), but there’s lots of new information too. Here are some notes:
include to eliminate N+1 queries.acts_as_tree that reintroduce lots of queries in exchange for the improvement in abstraction.CASCADE since app won’t know about the deletionsselect option with PostgreSQL arrays to save on object creation. Questions from the audience about normalization vs efficiency.bool_or and GROUP BY to get the data in one fell swoop. Query time went from 2+ seconds to 64 ms.LIMIT and OFFSET when used with subselects. Some discussion of pagination with the audience. Here’s an excellent discussion of pagination alternatives written by Justin French.generate_series. Apparently these functions cannot generate hints for the planner.

