From: Mark Williams <mark.williams@jivesoftware.com>
Cc: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: Bad Query Plan with Range Query
Date: Fri, 15 Apr 2011 15:29:10 -0700
Message-ID: <4DA8C6B6.3030702@jivesoftware.com> (raw)
In-Reply-To: <4DA84476020000250003C8A2@gw.wicourts.gov>
References: <4DA87DAC.30006@jivesoftware.com>
<4DA83FFA020000250003C89D@gw.wicourts.gov>
<4DA8893B.8050403@jivesoftware.com>
<4DA84476020000250003C8A2@gw.wicourts.gov>
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<mark.williams@jivesoftware.com> wrote:
>
>> If I re-write the query like this:
>>
>> explain SELECT messageID FROM Message WHERE modificationDate>=
>> 1302627793988 ORDER BY modificationDate LIMIT 1;
>
>> I also get a better plan.
>
> Yeah, but it's not necessarily the same value. Do you want the
> minimum messageID where modificationDate>= 1302627793988 or do you
> want the messageID of some row (possibly of many) with the minimum
> modificationDate where modificationDate>= 1302627793988?
>
> Since you're asking for a logically different value with that query,
> it's not surprising it uses a different plan.
>
> -Kevin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: mark.williams@jivesoftware.com
Subject: Re: Bad Query Plan with Range Query
In-Reply-To: <4DA8C6B6.3030702@jivesoftware.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox