pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Josh Berkus <josh@agliodbs.com>
Cc: Claudio Freire <klaussfreire@gmail.com>
Cc: postgres performance list <pgsql-performance@postgresql.org>
Subject: Re: Shouldn't we have a way to avoid "risky" plans?
Date: Fri, 25 Mar 2011 10:24:44 -0400
Message-ID: <3210.1301063084@sss.pgh.pa.us> (raw)
In-Reply-To: <4D8A8AB8.7040401@agliodbs.com>
References: <4D8A29F2.9080105@agliodbs.com>
	<AANLkTi=GAz7gFBCoXQeRDN3PUA0fXxRyP_=DxS4Y1tJU@mail.gmail.com>
	<4D8A581D.5080704@agliodbs.com>
	<AANLkTi=RXUSrCxqz3=BkAiixuenu2gf-K+W15Wz4McXH@mail.gmail.com>
	<4286.1300914004@sss.pgh.pa.us>
	<4D8A8AB8.7040401@agliodbs.com>

Josh Berkus <josh@agliodbs.com> writes:
>> If the planner starts operating on the basis of worst case rather than
>> expected-case performance, the complaints will be far more numerous than
>> they are today.

> Yeah, I don't think that's the way to go.  The other thought I had was
> to accumulate a "risk" stat the same as we accumulate a "cost" stat.

> However, I'm thinking that I'm overengineering what seems to be a fairly
> isolated problem, in that we might simply need to adjust the costing on
> this kind of a plan.

mergejoinscansel doesn't currently try to fix up the histogram bounds by
consulting indexes.  At the time I was afraid of the costs of doing
that, and I still am; but it would be a way to address this issue.

Author: Tom Lane <tgl@sss.pgh.pa.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



view thread (24+ messages)  latest in thread

Message-ID: <3210.1301063084@sss.pgh.pa.us>
Permalink:  ../3210.1301063084@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3210.1301063084@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, josh@agliodbs.com, klaussfreire@gmail.com
  Subject: Re: Shouldn't we have a way to avoid "risky" plans?
  In-Reply-To: <3210.1301063084@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox