Re: Query optimizer plans with very small selectivity estimates

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Matthew Bellew <matthewb(at)labkey(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Query optimizer plans with very small selectivity estimates
Date: 2015-10-30 00:00:07
Message-ID: 5632B307.2000905@agliodbs.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On 10/29/2015 11:24 AM, Tom Lane wrote:
> Matthew Bellew <matthewb(at)labkey(dot)com> writes:
>> I made have several users encounter performance problems, which all
>> seem to come down to this problem: multiplying selectivity estimates can
>> cause tuple estimates to grow very small very quickly, once the estimator
>> gets to 1 row, the planner may choose plans that are very good ONLY WHEN
>> there is exactly 1 row (maybe even O(N^large)). Unfortunately, these may
>> be the worst plans if the estimate is even slightly off (even just
>> returning 2 or 3 rows versus 1).
>
> Yeah, this is a well-known problem. There has been prior discussion along
> the same lines as you mention (only believe 1-row estimates when it's
> provably true that there's at most one row), but it hasn't looked like an
> easy change. See the pgsql-hackers archives for previous threads.

Also see Tomas's correlated stats patch submitted for 9.6.

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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Andrey Osenenko 2015-11-02 06:52:33 GIN index always doing Re-check condition, postgres 9.1
Previous Message Tom Lane 2015-10-29 18:24:07 Re: Query optimizer plans with very small selectivity estimates