From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Christophe Pettus <xof(at)thebuild(dot)com> |
Cc: | jinhui(dot)lai(at)qq(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #19059: PostgreSQL fails to evaluate the cheaper expression first, leading to 45X performance degradation |
Date: | 2025-09-20 23:19:03 |
Message-ID: | 2524033.1758410343@sss.pgh.pa.us |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Christophe Pettus <xof(at)thebuild(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Vik Fearing | 2025-09-21 09:09:02 | Re: BUG #19059: PostgreSQL fails to evaluate the cheaper expression first, leading to 45X performance degradation |
Previous Message | Christophe Pettus | 2025-09-20 22:54:54 | Re: BUG #19059: PostgreSQL fails to evaluate the cheaper expression first, leading to 45X performance degradation |