Falling back to the rails code for pk_and_sequence_for doesn't work
because we still wind up retrying the slow version of the query for
tables with no primary key. So just replace it instead.
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.