Re: [PERFORM] bad selectivity estimates for CASE

2009-01-06 Thread Robert Haas
On Mon, Jan 5, 2009 at 11:40 PM, Tom Lane t...@sss.pgh.pa.us wrote: Robert Haas robertmh...@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

Re: [PERFORM] bad selectivity estimates for CASE

2009-01-06 Thread Tom Lane
Robert Haas robertmh...@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

[PERFORM] bad selectivity estimates for CASE

2009-01-05 Thread Robert Haas
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. This also happens on HEAD. psql (8.4devel) Type help for help. head=# create table tenk (c) as select

Re: [PERFORM] bad selectivity estimates for CASE

2009-01-05 Thread Tom Lane
Robert Haas robertmh...@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