Re: [PERFORM] BETWEEN optimizer problems with single-value

2006-03-16 Thread Simon Riggs
On Thu, 2006-03-16 at 14:45 -0500, Tom Lane wrote: > Simon Riggs <[EMAIL PROTECTED]> writes: > > [BTW how do you add new indexes to system tables? I want to add one to > > pg_inherits but not sure where to look.] > > src/include/catalog/indexing.h > > Offhand I think adding a new entry is all you

Re: [PERFORM] BETWEEN optimizer problems with single-value

2006-03-16 Thread Tom Lane
Simon Riggs <[EMAIL PROTECTED]> writes: > I was thinking that we would fill out the OpExpr with different > opclasses for each plan, so each one sees a different story. (I was > thinking there was a clauselist for each plan; if not, there could be.) This is backwards: there isn't a plan yet. If t

Re: [PERFORM] BETWEEN optimizer problems with single-value

2006-03-16 Thread Simon Riggs
On Thu, 2006-03-16 at 15:41 -0400, Alvaro Herrera wrote: > Simon Riggs wrote: > > > [BTW how do you add new indexes to system tables? I want to add one to > > pg_inherits but not sure where to look.] > > See src/include/catalog/indexing.h -- I don't remember if there's > anything else that needs

Re: [PERFORM] BETWEEN optimizer problems with single-value

2006-03-16 Thread Alvaro Herrera
Simon Riggs wrote: > [BTW how do you add new indexes to system tables? I want to add one to > pg_inherits but not sure where to look.] See src/include/catalog/indexing.h -- I don't remember if there's anything else that needs modification. -- Alvaro Herrerahttp:/

Re: [PERFORM] BETWEEN optimizer problems with single-value

2006-03-16 Thread Simon Riggs
On Thu, 2006-03-16 at 10:57 -0500, Tom Lane wrote: > Simon Riggs <[EMAIL PROTECTED]> writes: > > Trying to get the information in the wrong place would be very > > expensive, I agree. But preparing that information when we have access > > to it and passing it through the plan would be much cheaper.

Re: [PERFORM] BETWEEN optimizer problems with single-value

2006-03-16 Thread Tom Lane
Simon Riggs <[EMAIL PROTECTED]> writes: > Trying to get the information in the wrong place would be very > expensive, I agree. But preparing that information when we have access > to it and passing it through the plan would be much cheaper. Where would that be? > The operator and the opclass are

Re: [PERFORM] BETWEEN optimizer problems with single-value

2006-03-16 Thread Simon Riggs
On Wed, 2006-03-15 at 21:05 -0500, Tom Lane wrote: > So we need a more accurate estimate for the boundary case. Agreed. > > Using 1.0e-10 isn't very useful... the selectivity for a range should > > never be less than the selectivity for an equality, so we should simply > > put in a test against o

Re: [PERFORM] BETWEEN optimizer problems with single-value

2006-03-15 Thread Tom Lane
Simon Riggs <[EMAIL PROTECTED]> writes: >> ISTM that when the BETWEEN constants match we end up in this part of >> clauselist_selectivity()... Yeah, I think you are right. > so that the planner underestimates the cost of using "Cal_CalDate" so > that it ends up the same as "Cal_CtofcNo", and then

Re: [PERFORM] BETWEEN optimizer problems with single-value

2006-03-15 Thread Simon Riggs
On Thu, 2006-03-16 at 00:07 +, Simon Riggs wrote: > On Wed, 2006-03-15 at 14:17 -0500, Tom Lane wrote: > > > It looks to me like this is a matter of bad cost estimation, ie, it's > > thinking the other index is cheaper to use. Why that is is not clear. > > Can we see the pg_stats rows for cto

Re: [PERFORM] BETWEEN optimizer problems with single-value

2006-03-15 Thread Simon Riggs
On Wed, 2006-03-15 at 14:17 -0500, Tom Lane wrote: > It looks to me like this is a matter of bad cost estimation, ie, it's > thinking the other index is cheaper to use. Why that is is not clear. > Can we see the pg_stats rows for ctofcNo and calDate? ISTM that when the BETWEEN constants match we

Re: [PERFORM] BETWEEN optimizer problems with single-value range

2006-03-15 Thread Merlin Moncure
On 3/15/06, Andreas Kretschmer <[EMAIL PROTECTED]> wrote: > Merlin Moncure <[EMAIL PROTECTED]> schrieb: > > > On 3/15/06, Kevin Grittner <[EMAIL PROTECTED]> wrote: > > > Attached is a simplified example of a performance problem we have seen, > > > with a workaround and a suggestion for enhancement

Re: [PERFORM] BETWEEN optimizer problems with single-value range

2006-03-15 Thread Andreas Kretschmer
Merlin Moncure <[EMAIL PROTECTED]> schrieb: > On 3/15/06, Kevin Grittner <[EMAIL PROTECTED]> wrote: > > Attached is a simplified example of a performance problem we have seen, > > with a workaround and a suggestion for enhancement (hence both the > > performance and hackers lists). > > > Hi Kevi

Re: [PERFORM] BETWEEN optimizer problems with single-value

2006-03-15 Thread Kevin Grittner
>>> On Wed, Mar 15, 2006 at 1:17 pm, in message <[EMAIL PROTECTED]>, Tom Lane <[EMAIL PROTECTED]> wrote: > > 8.1 is certainly capable of devising the plan you want, for example > in the regression database: > > regression=# explain select * from tenk1 where thousand = 10 and tenthous > between

Re: [PERFORM] BETWEEN optimizer problems with single-value range

2006-03-15 Thread Merlin Moncure
On 3/15/06, Kevin Grittner <[EMAIL PROTECTED]> wrote: > Attached is a simplified example of a performance problem we have seen, > with a workaround and a suggestion for enhancement (hence both the > performance and hackers lists). Hi Kevin. In postgres 8.2 you will be able to use the row-wise co

Re: [PERFORM] BETWEEN optimizer problems with single-value

2006-03-15 Thread Tom Lane
"Kevin Grittner" <[EMAIL PROTECTED]> writes: >> Odd. Can you tell us your PG- Version? > this is 8.1.2 with some 8.1.3 changes plus the string literal patch.) 8.1 is certainly capable of devising the plan you want, for example in the regression database: regression=# explain select * from tenk1

Re: [PERFORM] BETWEEN optimizer problems with single-value

2006-03-15 Thread Kevin Grittner
>>> On Wed, Mar 15, 2006 at 12:17 pm, in message <[EMAIL PROTECTED]>, Andreas Kretschmer <[EMAIL PROTECTED]> wrote: > Kevin Grittner <[EMAIL PROTECTED]> schrieb: > >> Attached is a simplified example of a performance problem we have seen, > > Odd. Can you tell us your PG- Version? I know we rea

Re: [PERFORM] BETWEEN optimizer problems with single-value range

2006-03-15 Thread Andreas Kretschmer
Kevin Grittner <[EMAIL PROTECTED]> schrieb: > Attached is a simplified example of a performance problem we have seen, Odd. Can you tell us your PG-Version? Andreas -- Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect.

[PERFORM] BETWEEN optimizer problems with single-value range

2006-03-15 Thread Kevin Grittner
Attached is a simplified example of a performance problem we have seen, with a workaround and a suggestion for enhancement (hence both the performance and hackers lists). Our software is allowing users to specify the start and end dates for a query. When they enter the same date for both, the opt