Monkey patch rails to make system table query efficient
authorTom Hughes <tom@compton.nu>
Mon, 14 Jun 2010 11:43:39 +0000 (12:43 +0100)
committerTom Hughes <tom@compton.nu>
Mon, 14 Jun 2010 11:43:39 +0000 (12:43 +0100)
commita0af70cfb4b7ab179014050ce026ab054025a65e
treeb74ac9a7485912d3e39f4ff757855c180c81d68a
parent180228b7e36224fefd5540306d7fb77799d4b827
Monkey patch rails to make system table query efficient

Rails tries to query the system tables to find the primary key
and it's controlling sequence, but it doesn't specify that it is
looking for objects of class "pg_class" so the pg_depend table
has to be sequentially scanned instead of being accessed using
the index.

Tests on the production database show that the time taken for
this query drops from 3.5s to 15ms if the index is used.
config/initializers/postgresql_adapter.rb [new file with mode: 0644]