Re: Updating histogram_bounds after a delete

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
Cc: "Derrick Rice" <derrick(dot)rice(at)gmail(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Updating histogram_bounds after a delete
Date: 2011-03-17 15:00:59
Message-ID: 12606.1300374059@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

"Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov> writes:
> Derrick Rice <derrick(dot)rice(at)gmail(dot)com> wrote:
>> Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov wrote:
>>> there is a feature to probe the end of an index's range in
>>> situations where data skew was often causing less than optimal
>>> plans to be chosen.

>> Was this introduced in 9.0 or was it earlier?

> I don't remember when it was added. I took a stab at searching for
> it, but didn't get it figured out; if nobody who knows off-hand
> jumps in, I'll try again when I have more time.

Author: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Branch: master Release: REL9_0_BR [40608e7f9] 2010-01-04 02:44:40 +0000

When estimating the selectivity of an inequality "column > constant" or
"column < constant", and the comparison value is in the first or last
histogram bin or outside the histogram entirely, try to fetch the actual
column min or max value using an index scan (if there is an index on the
column). If successful, replace the lower or upper histogram bound with
that value before carrying on with the estimate. This limits the
estimation error caused by moving min/max values when the comparison
value is close to the min or max. Per a complaint from Josh Berkus.

It is tempting to consider using this mechanism for mergejoinscansel as well,
but that would inject index fetches into main-line join estimation not just
endpoint cases. I'm refraining from that until we can get a better handle
on the costs of doing this type of lookup.

regards, tom lane

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Kevin Grittner 2011-03-17 15:05:02 Re: Updating histogram_bounds after a delete
Previous Message Kenneth Marshall 2011-03-17 14:55:29 Re: Updating histogram_bounds after a delete