From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: bad selectivity estimates for CASE
Date: Tue, 06 Jan 2009 08:22:00 -0500
Message-ID: <7832.1231248120@sss.pgh.pa.us> (raw)
In-Reply-To: <603c8f070901060425t485fb8d8nb79735ed72982d5a@mail.gmail.com>
References: <603c8f070901051915p15b3d6a7jbe6f6fdd178143e@mail.gmail.com>
<3032.1231216843@sss.pgh.pa.us>
<603c8f070901060425t485fb8d8nb79735ed72982d5a@mail.gmail.com>
"Robert Haas" <robertmhaas@gmail.com> writes:
> Well, presumably CASE WHEN <expr1> THEN <constant1> WHEN <expr2> THEN
> <constant2> WHEN <expr3> THEN <constant3> ... END = <constantn> could
> be simplified to <exprn>.
Not without breaking the order-of-evaluation guarantees. Consider
case when x=0 then 0 when 1/x = 42 then 1 end = 1
This expression should not suffer a divide-by-zero failure but your
proposal would allow it to do so.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: tgl@sss.pgh.pa.us, robertmhaas@gmail.com
Subject: Re: bad selectivity estimates for CASE
In-Reply-To: <7832.1231248120@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox