Re: functions: VOLATILE performs better than STABLE - Mailing list pgsql-performance

From David Rowley
Subject Re: functions: VOLATILE performs better than STABLE
Date
Msg-id CAKJS1f8QwuNP9anQbPwcr4RLDR3JvW31c3L_H95tpn9HB2Fj8A@mail.gmail.com
Whole thread Raw
In response to Re: functions: VOLATILE performs better than STABLE  (Laurenz Albe <laurenz.albe@cybertec.at>)
List pgsql-performance
On 25 March 2018 at 18:00, Laurenz Albe <laurenz.albe@cybertec.at> wrote:
> Peter wrote:
>> Over all, VOLATILE performs better than STABLE.
>
> The reason is that the subquery with the VOLATILE function can be
> flattened; see the EXPLAIN (VERBOSE) output.
>
> There is not guarantee that less volatility means better performance.

Although, it would be nice.

TPC-H Q1 does appear to be crafted to allow database with smarter
expression evaluation to get a better score.

It would probably require some sort of recursive expression evaluation
where at each level we check if that expression has already been seen,
if it has, then replace it with some sort of placeholder, then
evaluate each placeholder in the required order.

Probably the first part could be done during planning.  It would mean
targetlists would need to carry a bit more weight.

It would be an interesting project to work on, but not planning to personally.

-- 
 David Rowley                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


pgsql-performance by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: Should from_collapse be switched off? (queries 10 times faster)
Next
From: bk@e8s.de
Date:
Subject: Re: Slow planning time for custom function