Re: Recognizing range constraints (was Re: [PERFORM] Plan for relatively simple query seems to be very inefficient) - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Recognizing range constraints (was Re: [PERFORM] Plan for relatively simple query seems to be very inefficient)
Date
Msg-id 6594.1112826910@sss.pgh.pa.us
Whole thread Raw
In response to Re: Recognizing range constraints (was Re: [PERFORM] Plan for relatively simple query seems to be very inefficient)  ("Jim C. Nasby" <decibel@decibel.org>)
Responses Re: Recognizing range constraints (was Re: [PERFORM] Plan for relatively simple query seems to be very inefficient)
Re: Recognizing range constraints (was Re: [PERFORM] Plan
List pgsql-hackers
"Jim C. Nasby" <decibel@decibel.org> writes:
> On Wed, Apr 06, 2005 at 06:09:37PM -0400, Tom Lane wrote:
>> Can anyone suggest a more general rule?  Do we need for example to
>> consider whether the relation membership is the same in two clauses
>> that might be opposite sides of a range restriction?  It seems like
>>
>> a.x > b.y AND a.x < b.z

> In a case like this, you could actually look at the  data in b and see
> what the average range size is.

Not with the current statistics --- you'd need some kind of cross-column
statistics involving both y and z.  (That is, I doubt it would be
helpful to estimate the average range width by taking the difference of
independently-calculated mean values of y and z ...)  But yeah, in
principle it would be possible to make a non-default estimate.

            regards, tom lane

pgsql-hackers by date:

Previous
From: "Jim C. Nasby"
Date:
Subject: Re: Recognizing range constraints (was Re: [PERFORM] Plan for relatively simple query seems to be very inefficient)
Next
From: Tom Lane
Date:
Subject: Re: Recognizing range constraints (was Re: [PERFORM] Plan for relatively simple query seems to be very inefficient)