Re: [HACKERS] Improving non-joinable EXISTS subqueries

2008-08-22 Thread Decibel!
On Aug 20, 2008, at 12:43 PM, Tom Lane wrote: We have speculated in the past about having alternative plans that could be conditionally executed based on information not available at planning time. This could be seen as a first experiment in that direction. I am not thinking of a general-purpos

Re: [HACKERS] Improving non-joinable EXISTS subqueries

2008-08-20 Thread Robert Haas
> Another technique that we could play with is to have the > AlternativeSubPlans node track the actual number of calls it gets, > and switch from the "retail" implementation to the "hashed" > implementation if that exceeds a threshold. This'd provide some > robustness in the face of bad estimates,

Re: [HACKERS] Improving non-joinable EXISTS subqueries

2008-08-20 Thread Kevin Grittner
>>> Tom Lane <[EMAIL PROTECTED]> wrote: > when we have an EXISTS that could be done both ways, > why not just generate plans for both ways, and leave the decision > which to use until later? That seems good to me. The costs for the slower plan generally come out much higher. When the run tim

Re: [HACKERS] Improving non-joinable EXISTS subqueries

2008-08-20 Thread Tom Lane
"Kevin Grittner" <[EMAIL PROTECTED]> writes: > Tom Lane <[EMAIL PROTECTED]> wrote: >> [ complicated scheme for improving planning of EXISTS ] > So I'd be very happy to see this work done, not because I can't find a > workaround, but because trying to teach all the programmers tricky > hand-optim

Re: [HACKERS] Improving non-joinable EXISTS subqueries

2008-08-19 Thread Kevin Grittner
>>> Tom Lane <[EMAIL PROTECTED]> wrote: > The examples that Kevin Grittner put up awhile back included several > uses of EXISTS() in places where it couldn't be turned into a semijoin, > eg in the query's targetlist. I was musing a bit about whether we could > improve those scenarios. I would

Re: [HACKERS] Improving non-joinable EXISTS subqueries

2008-08-19 Thread Stephen Frost
* Tom Lane ([EMAIL PROTECTED]) wrote: > So ... I'm wondering if this actually touches anyone's hot-button, > or if we should just file it in the overflowing pile of Things That > Might Be Nice To Do Someday. What bugs me the most about having IN() be faster than EXISTS() in certain situations is t

Re: [HACKERS] Improving non-joinable EXISTS subqueries

2008-08-18 Thread Alvaro Herrera
Tom Lane wrote: > I don't think any of this is out of reach, but it'd be a nontrivial > bit of implementation effort (maybe a week or three) and it also looks > like there might be a measurable planning slowdown for any query > involving subqueries. I'm not sure yet how much of this is just movin

[HACKERS] Improving non-joinable EXISTS subqueries

2008-08-18 Thread Tom Lane
The examples that Kevin Grittner put up awhile back included several uses of EXISTS() in places where it couldn't be turned into a semijoin, eg in the query's targetlist. I was musing a bit about whether we could improve those scenarios. I would like to get 8.4 to the point where we could say as