Re: Weird, bad 0.5% selectivity estimate for a column equal to itself

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Weird, bad 0.5% selectivity estimate for a column equal to itself
Date: 2013-06-21 22:21:28
Message-ID: 51C4D1E8.6090602@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On 06/21/2013 02:32 PM, Tom Lane wrote:
> Josh Berkus <josh(at)agliodbs(dot)com> writes:
>> I'm getting something really odd in 9.2.4, where the planner estimates
>> that the selectivity of a column equal to itself is always exactly 0.5%
>> (i.e. 0.005X). I can't figure out where this constant is coming from,
>> or why it's being applied.
>
> See DEFAULT_EQ_SEL.

Why is it using that? We have statistics on the column. What reason
would it have for using a default estimate?

> But why exactly do you care? Surely it's a stupid
> query and you should fix it.

(a) that test case is a substantial simplication of a much more complex
query, one which exhibits actual execution time issues because of this
selectivity bug.

(b) that query is also auto-generated by external software, so "just fix
it" isn't as easy as it sounds.

(c) PostgreSQL ought to perform well even on the stupid queries.

Obviously, we're going to code around this for the existing software,
but this is an example of a planner bug which should be on the fix list.

--
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2013-06-22 20:24:48 Re: Weird, bad 0.5% selectivity estimate for a column equal to itself
Previous Message Tom Lane 2013-06-21 21:32:58 Re: Weird, bad 0.5% selectivity estimate for a column equal to itself