Forum Moderators: open
Simple example: SELECT field1, field2 FROM table WHERE user_id = 123 ORDER BY field1 DESC LIMIT 10
This table has 450,000 rows. The user_id field is indexed. The query takes 8 seconds, in some cases. I can't believe it's so slow. EXPLAIN shows it uses the index for some user_ids, does a full scan for others.
I do other queries on the same table, joining other tables, too. These execute in milliseconds. Postgres seems to arbitrarily hate some of my queries.
Any ideas on where I should start, to get to the bottom of this?