Forum Moderators: open

Message Too Old, No Replies

Postgres Performance Problems

little help?

         

FourDegreez

4:08 am on May 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Some queries are lightning quick, others are painfully slow. I don't see any obvious reason for the slow ones, though.

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?

Achernar

4:32 pm on May 22, 2007 (gmt 0)

10+ Year Member Top Contributors Of The Month



Try adding single quotes around the value.
user_id = '123'

You can also try to reindex the table. Sometimes index get corrupted.