From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Neil Conway <neilc(at)samurai(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Optimizing maximum/minimum queries (yet again) |
Date: | 2005-04-09 04:26:36 |
Message-ID: | 19257.1113020796@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Neil Conway <neilc(at)samurai(dot)com> writes:
> Does this transformation work for a query of the form:
> SELECT min(x), max(y) FROM tab WHERE random() > 0.5;
I've been going back and forth on that. We wouldn't lose a lot in the
real world if we simply abandoned the optimization attempt whenever we
find any volatile functions in WHERE. OTOH you could also argue that
we have never guaranteed that volatile functions in WHERE would be
evaluated at every table row --- consider something like
SELECT ... WHERE x > 42 AND random() > 0.5;
All that this optimization might do is to further cut the fraction of
table rows at which the volatile function actually gets checked. So
I'm not seeing that it would break any code that worked reliably before.
Still, if it makes you feel at all uncomfortable, we can just refuse
the optimization in such cases.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2005-04-09 04:46:51 | Re: [PATCHES] DELETE ... USING |
Previous Message | Neil Conway | 2005-04-09 04:19:19 | Re: Optimizing maximum/minimum queries (yet again) |