Re: [PERFORM] Automatic optimization of IN clauses via INNER JOIN

2009-12-18 Thread Robert Haas
On Fri, Dec 18, 2009 at 7:32 PM, Tom Lane wrote: > Robert Haas writes: >> If at least one column in the subselect is strict, you can rewrite it >> that way yourself, but the optimizer won't do it. I wish it did, but I >> don't wish it badly enough to have written the code myself, and >> apparentl

Re: [PERFORM] Automatic optimization of IN clauses via INNER JOIN

2009-12-18 Thread Tom Lane
Robert Haas writes: > If at least one column in the subselect is strict, you can rewrite it > that way yourself, but the optimizer won't do it. I wish it did, but I > don't wish it badly enough to have written the code myself, and > apparently neither does anyone else. I was thinking about this e

Re: [PERFORM] Automatic optimization of IN clauses via INNER JOIN

2009-12-18 Thread Robert Haas
2009/12/18 Grzegorz Jaśkiewicz : > 2009/12/18 Robert Haas : >> 2009/12/18 Grzegorz Jaśkiewicz : >>> On Fri, Dec 18, 2009 at 2:18 PM, Robert Haas wrote: >>> NOT IN is the only that really kills you as far as optimization is concerned.  IN can be transformed to a join.  NOT IN forces a NOT

Re: [PERFORM] Automatic optimization of IN clauses via INNER JOIN

2009-12-18 Thread Grzegorz Jaśkiewicz
2009/12/18 Robert Haas : > 2009/12/18 Grzegorz Jaśkiewicz : >> On Fri, Dec 18, 2009 at 2:18 PM, Robert Haas wrote: >> >>> NOT IN is the only that really kills you as far as optimization is >>> concerned.  IN can be transformed to a join.  NOT IN forces a NOT >>> (subplan)-type plan, which bites -

Re: [PERFORM] Automatic optimization of IN clauses via INNER JOIN

2009-12-18 Thread Robert Haas
2009/12/18 Grzegorz Jaśkiewicz : > On Fri, Dec 18, 2009 at 2:18 PM, Robert Haas wrote: > >> NOT IN is the only that really kills you as far as optimization is >> concerned.  IN can be transformed to a join.  NOT IN forces a NOT >> (subplan)-type plan, which bites - hard. > > in a well designed dat

Re: [PERFORM] Automatic optimization of IN clauses via INNER JOIN

2009-12-18 Thread Grzegorz Jaśkiewicz
On Fri, Dec 18, 2009 at 2:18 PM, Robert Haas wrote: > NOT IN is the only that really kills you as far as optimization is > concerned.  IN can be transformed to a join.  NOT IN forces a NOT > (subplan)-type plan, which bites - hard. in a well designed database (read: not abusing NULLs) - it can b

Re: [PERFORM] Automatic optimization of IN clauses via INNER JOIN

2009-12-18 Thread Robert Haas
On Thu, Dec 17, 2009 at 9:20 PM, Craig Ringer wrote: > On 17/12/2009 11:57 PM, Tom Lane wrote: >> >> Thomas Hamilton  writes: >>> >>> But in our testing under the same optimization and conditions INNER JOIN >>> is significantly outperforming IN. >> >> [ shrug... ]  You haven't provided any details

Re: [PERFORM] Automatic optimization of IN clauses via INNER JOIN

2009-12-17 Thread Craig Ringer
On 17/12/2009 11:57 PM, Tom Lane wrote: Thomas Hamilton writes: But in our testing under the same optimization and conditions INNER JOIN is significantly outperforming IN. [ shrug... ] You haven't provided any details, so it's impossible to offer any useful advice. In other words: can we

Re: [PERFORM] Automatic optimization of IN clauses via INNER JOIN

2009-12-17 Thread Grzegorz Jaśkiewicz
On Thu, Dec 17, 2009 at 6:05 PM, Robert Haas wrote: > On Thu, Dec 17, 2009 at 10:23 AM, Thomas Hamilton > wrote: >> Apparently the latest version of MySQL has solved this problem: >> http://www.xaprb.com/blog/2006/06/28/why-large-in-clauses-are-problematic/ >> >> But I am running PostgreSQL v8.3

Re: [PERFORM] Automatic optimization of IN clauses via INNER JOIN

2009-12-17 Thread Robert Haas
On Thu, Dec 17, 2009 at 10:23 AM, Thomas Hamilton wrote: > Apparently the latest version of MySQL has solved this problem: > http://www.xaprb.com/blog/2006/06/28/why-large-in-clauses-are-problematic/ > > But I am running PostgreSQL v8.3 and am observing generally that SELECT ... > WHERE ... IN (

Re: [PERFORM] Automatic optimization of IN clauses via INNER JOIN

2009-12-17 Thread Tom Lane
Thomas Hamilton writes: > But in our testing under the same optimization and conditions INNER JOIN is > significantly outperforming IN. [ shrug... ] You haven't provided any details, so it's impossible to offer any useful advice. regards, tom lane -- Sent via pgsql-pe

Re: [PERFORM] Automatic optimization of IN clauses via INNER JOIN

2009-12-17 Thread Thomas Hamilton
Yes, I see the one note that running Analyze can improve the performance. But in our testing under the same optimization and conditions INNER JOIN is significantly outperforming IN. - Original Message From: Tom Lane t...@sss.pgh.pa.us Thomas Hamilton writes: > Apparently the latest

Re: [PERFORM] Automatic optimization of IN clauses via INNER JOIN

2009-12-17 Thread Tom Lane
Thomas Hamilton writes: > Apparently the latest version of MySQL has solved this problem: > http://www.xaprb.com/blog/2006/06/28/why-large-in-clauses-are-problematic/ > But I am running PostgreSQL v8.3 and am observing generally that SELECT ... > WHERE ... IN (a, b, c, ...) is much slower than S