Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id C648D6321BD for ; Tue, 6 Jan 2009 00:40:48 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 60824-08 for ; Tue, 6 Jan 2009 00:40:46 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 08B206321BA for ; Tue, 6 Jan 2009 00:40:45 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id n064ehuC003033; Mon, 5 Jan 2009 23:40:43 -0500 (EST) To: "Robert Haas" cc: "pgsql-performance@postgresql.org" Subject: Re: bad selectivity estimates for CASE In-reply-to: <603c8f070901051915p15b3d6a7jbe6f6fdd178143e@mail.gmail.com> References: <603c8f070901051915p15b3d6a7jbe6f6fdd178143e@mail.gmail.com> Comments: In-reply-to "Robert Haas" message dated "Mon, 05 Jan 2009 22:15:29 -0500" Date: Mon, 05 Jan 2009 23:40:43 -0500 Message-ID: <3032.1231216843@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200901/8 X-Sequence-Number: 32287 "Robert Haas" 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... regards, tom lane