Re: Optimizing maximum/minimum queries (yet again) - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Optimizing maximum/minimum queries (yet again)
Date
Msg-id 19604.1113024309@sss.pgh.pa.us
Whole thread Raw
In response to Re: Optimizing maximum/minimum queries (yet again)  (Bruno Wolff III <bruno@wolff.to>)
List pgsql-hackers
Bruno Wolff III <bruno@wolff.to> writes:
> Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> I don't have a problem with that, but I haven't quite convinced myself
>> that we need to expend the cycles to check for it, either ...

> I would expect that the sequential plan would be better for a volatile
> where clause since you are going to execute it for every row anyway.

Well, no, wait a minute.  We have never promised that we would
physically evaluate every volatile function at every table row.
What we promise is that we do not assume-without-proof that the
function's value will be the same at every table row.  I don't see
where this optimization breaks that promise.

Obviously, we do make such an assumption for WHERE clauses that actually
get taken into the indexscan condition.  But we already check volatility
before considering a clause as a possible indexscan condition.  The
question here is whether we have to reject the optimization if there are
additional WHERE clauses, not directly related to the proposed
indexscan, that contain volatile functions.  I'm not seeing the argument
that says we must do that.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: Optimizing maximum/minimum queries (yet again)
Next
From: Tom Lane
Date:
Subject: Re: [GENERAL] table and column information from cursor?