Re: Performance regressions found using sqlfuzz - Mailing list pgsql-performance

From Tom Lane
Subject Re: Performance regressions found using sqlfuzz
Date
Msg-id 27505.1550356669@sss.pgh.pa.us
Whole thread Raw
In response to Re: Performance regressions found using sqlfuzz  (Andres Freund <andres@anarazel.de>)
Responses Re: Performance regressions found using sqlfuzz
List pgsql-performance
Andres Freund <andres@anarazel.de> writes:
> On 2019-02-14 17:27:40 +0000, Jung, Jinho wrote:
>> - Our analysis: We believe that this regression has to do with two factors: 1) conditional expression (e.g., LEAST
orNULLIF) are not reduced to constants unlike string functions (e.g., CHAR_LENGTH)  2) change in the cost estimation
functionfor bitmap scan. Execution time grows by 3 orders of magnitude.  We note that this regression is only observed
onlarge databases (e.g., scale factor of 50). 

> Hm. The primary problem here is that the estimation both before and
> after are really bad. So I don't think the commit you point out here is
> really to blame.  I'm not that bothered by the query not being great,
> given the weird construction with LEAST(), but we probably could fix
> that pretty easily.

We already did:

Author: Tom Lane <tgl@sss.pgh.pa.us>
Branch: master [6f19a8c41] 2018-12-30 13:42:04 -0500

    Teach eval_const_expressions to constant-fold LEAST/GREATEST expressions.

    Doing this requires an assumption that the invoked btree comparison
    function is immutable.  We could check that explicitly, but in other
    places such as contain_mutable_functions we just assume that it's true,
    so we may as well do likewise here.  (If the comparison function's
    behavior isn't immutable, the sort order in indexes built with it would
    be unstable, so it seems certainly wrong for it not to be so.)

    Vik Fearing

    Discussion: https://postgr.es/m/c6e8504c-4c43-35fa-6c8f-3c0b80a912cc@2ndquadrant.com

BTW, const-folding NULLIF would not be a similarly tiny fix, because
it would need to check for immutability of the underlying operator
(since it is possibly a cross-type comparison, we can't get
away with just assuming it's immutable).  I'm not convinced that
case is worth carrying extra code for.

            regards, tom lane


pgsql-performance by date:

Previous
From: Justin Pryzby
Date:
Subject: Re: constraint exclusion with ineq condition (Re: server hardwaretuning.)
Next
From: Justin Pryzby
Date:
Subject: Re: dsa_allocate() faliure