"Steinar H. Gunderson" <sgunderson(at)bigfoot(dot)com> writes:
> On Sun, Aug 29, 2004 at 06:03:43PM -0400, Tom Lane wrote:
>> The expression "now() - something" is not a constant, so the planner
>> is faced with "timestampfield > unknownvalue".
> Out of curiosity, does the subselect query I presented earlier in the thread
> count as "a constant"? It gives the correct query plan, but this could of
> course just be correct by accident...
That was on 7.2, wasn't it? I don't remember any longer exactly how 7.2
does this stuff, but it's different from 7.3 and later (and certainly
not any more "right").
You did at one time need to hide now() in a subselect to get the planner
to consider an indexscan at all --- that was before we made the
distinction between immutable and stable functions, and so now() had
to be treated as unsafe to index against (just as random() still is).
I think 7.2 behaved that way but I'm not totally sure.
regards, tom lane
In response to
pgsql-performance by date
|Next:||From: Martin Sarsale||Date: 2004-08-30 17:46:37|
|Subject: seqscan instead of index scan|
|Previous:||From: Steinar H. Gunderson||Date: 2004-08-30 16:02:28|
|Subject: Re: Why does a simple query not use an obvious index?|