Re: Performance of query (fwd)

From: Dmitry Tkach <dmitry(at)openratings(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Dann Corbit <DCorbit(at)connx(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Performance of query (fwd)
Date: 2003-06-11 15:29:59
Message-ID: 3EE74AF7.60708@openratings.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane wrote:

>I've thought about that ... but am not sure whether it wouldn't create
>as many problems as it solves. What are the consequences when the
>planner's pre-evaluation yields a different result from what actually
>happens at runtime? Hardly an unlikely scenario when dealing with
>stuff like now().
>
But isn't now() supposed to return the same value within the same
transaction?
Isn't that a guarantee, that it won't change between pre-evaluation and
actual execution?

> (And for actually constant expressions, say
>sin(pi), the result already does get folded to a constant. So only
>the nontrivial cases are left to think about.)
>
>
>In the case of functions with side-effects (think nextval()), the
>planner *must not* speculatively evaluate the function. We could
>introduce another function property-flag, like IMMUTABLE or STRICT,
>to govern this ... but I'm not sure it's worth the trouble.
>
>

I must be missing something here - isn't it enough to use the same logic
as when deciding whether the function output can be usedfor index scan?
In 7.2 conditions like 'where stamp < now()' were refusing to use the
index, because now() isn't immutable (cacheable)... I see that it is
fixed in 7.3 by adding another
flag - STABLE... It looks like the planner is now able to use the index
as long as the function is not volatile.
Can't the same criteria be applied to that pre-evaluation decision?

Dima

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dmitry Tkach 2003-06-11 15:32:19 Re: insert question..
Previous Message Jonathan Bartlett 2003-06-11 15:29:50 Re: Postgres performance comments from a MySQL user