Re: [PERFORM] Bad Query Plan with Range Query

2011-04-15 Thread Mark Williams
Whoops, I meant this query (ordering my messageid): SELECT messageID FROM Message WHERE modificationDate>= 1302627793988 ORDER BY messageID LIMIT 1; Sometimes this gives the better plan. But not always. On 04/15/2011 11:13 AM, Kevin Grittner wrote: Mark Williams wrote: If I re-wr

Re: [PERFORM] Bad Query Plan with Range Query

2011-04-15 Thread Mark Williams
) I also get a better plan. However, this is not always the case. On some other instances we still get a sequential scan on the primary key. On 04/15/2011 10:54 AM, Kevin Grittner wrote: Mark Williams wrote: explain SELECT min(messageID) FROM Message WHERE modificationDate>= 130262779

[PERFORM] Bad Query Plan with Range Query

2011-04-15 Thread Mark Williams
We are experiencing a problem with our query plans when using a range query in Postgresql 8.3. The query we are executing attempts to select the minimum primary key id after a certain date. Our date columns are bigint's holding a unix epoch representation of the date. We have an index on the pr