Re: bad selectivity estimates for CASE - Mailing list pgsql-performance

From Robert Haas
Subject Re: bad selectivity estimates for CASE
Date
Msg-id 603c8f070901060425t485fb8d8nb79735ed72982d5a@mail.gmail.com
Whole thread Raw
In response to Re: bad selectivity estimates for CASE  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: bad selectivity estimates for CASE
List pgsql-performance
On Mon, Jan 5, 2009 at 11:40 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> "Robert Haas" <robertmhaas@gmail.com> writes:
>> While looking at a complex query that is being poorly planned by
>> PostgreSQL 8.2.9, I discovered that any non-trivial CASE...WHEN
>> expression seems to produce a selectivity estimate of 0.005.
>
> If you have an idea for a non-silly estimate, feel free to enlighten
> us...

Well, presumably CASE WHEN <expr1> THEN <constant1> WHEN <expr2> THEN
<constant2> WHEN <expr3> THEN <constant3> ... END = <constantn> could
be simplified to <exprn>.  But that's not going to happen in time to
do me any good on this query, if it ever happens (and might not be
sufficient anyway since the selectivity estimates of <expr1> may not
be very good either), so I was more looking for suggestions on coping
with the situation, since I'm sure that I'm not the first person to
have this type of problem.

...Robert

pgsql-performance by date:

Previous
From: "Dmitry Koterov"
Date:
Subject: Re: Bgwriter and pg_stat_bgwriter.buffers_clean aspects
Next
From: Tom Lane
Date:
Subject: Re: bad selectivity estimates for CASE