Re: BUG #19059: PostgreSQL fails to evaluate the cheaper expression first, leading to 45X performance degradation - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #19059: PostgreSQL fails to evaluate the cheaper expression first, leading to 45X performance degradation
Date
Msg-id 2524033.1758410343@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #19059: PostgreSQL fails to evaluate the cheaper expression first, leading to 45X performance degradation  (Christophe Pettus <xof@thebuild.com>)
List pgsql-bugs
Christophe Pettus <xof@thebuild.com> writes:
> And tangentially, doesn't the SQL standard make it implementation-defined if OR short-circuits or not?

It looks like it says it's implementation-dependent, meaning
that not only is it not defined by the standard, but we're not
required to document it either:

    Subclause 6.3.3.3, “Rule evaluation order”:

    a) It is implementation-dependent whether expressions are
    actually evaluated from left to right when the precedence is
    not otherwise determined by the Formats or by parentheses.

    b) If evaluation of the inessential parts of an expression or
    search condition would cause an exception condition to be
    raised, then it is implementation-dependent whether or not
    that condition is raised.

    c) The declared type of a site that contains an intermediate
    result is implementation-dependent.

This is a good thing, because while we do mention boolean expression
re-ordering and short-circuiting, there's an awful lot of such details
that we've left undocumented.

            regards, tom lane



pgsql-bugs by date:

Previous
From: Christophe Pettus
Date:
Subject: Re: BUG #19059: PostgreSQL fails to evaluate the cheaper expression first, leading to 45X performance degradation
Next
From: Vik Fearing
Date:
Subject: Re: BUG #19059: PostgreSQL fails to evaluate the cheaper expression first, leading to 45X performance degradation