On Wed, Feb 1, 2012 at 11:48 AM, Alessandro Gagliardi <alessandro@xxxxxxxx> wrote: > LIMIT 65536; Total query runtime: 14846 ms. > - http://explain.depesz.com/s/I3E > LIMIT 69632: Total query runtime: 80141 ms. > - http://explain.depesz.com/s/9hp > > So it looks like when the limit crosses a certain threshold (somewhere north > of 2^16), Postgres decides to do a Seq Scan instead of an Index Scan. > I've already lowered random_page_cost to 2. Maybe I should lower it to 1.5? > Actually 60K should be plenty for my purposes anyway. It's important to set random_page_cost according to more than just one query, but yeah, at this point it's likely a good idea to set it closer to 1.0. You're on heroku right? Something closer to 1.0 is likely called for if so. 1.2 to 1.4 or so. If you've got other queries you can test the change on all the better. -- Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance