Re: [PERFORM] optimizing queries using IN and EXISTS

2012-07-19 Thread Nick Hofstede
: Re: [PERFORM] optimizing queries using IN and EXISTS Nick Hofstede writes: > I'm surprised at the difference in speed/execution plan between two > logically equivalent queries, one using IN, the other using EXISTS. > (At least I think they are logically equivalent) > SELE

Re: [PERFORM] optimizing queries using IN and EXISTS

2012-07-18 Thread Tom Lane
Nick Hofstede writes: > I'm surprised at the difference in speed/execution plan between two logically > equivalent queries, one using IN, the other using EXISTS. (At least I think > they are logically equivalent) > SELECT * > FROM foo > WHERE 'text6' IN (SELECT value >FRO

Re: [PERFORM] optimizing queries using IN and EXISTS

2012-07-18 Thread Nick Hofstede
Verzonden: woensdag 18 juli 2012 20:40 Aan: Nick Hofstede CC: pgsql-performance@postgresql.org Onderwerp: Re: [PERFORM] optimizing queries using IN and EXISTS On 18 July 2012 17:10, Nick Hofstede wrote: > Hi, > > I'm surprised at the difference in speed/execution plan between two logical

Re: [PERFORM] optimizing queries using IN and EXISTS

2012-07-18 Thread Peter Geoghegan
On 18 July 2012 17:10, Nick Hofstede wrote: > Hi, > > I'm surprised at the difference in speed/execution plan between two logically > equivalent queries, one using IN, the other using EXISTS. (At least I think > they are logically equivalent) They are not logically equivalent. http://www.postg

[PERFORM] optimizing queries using IN and EXISTS

2012-07-18 Thread Nick Hofstede
Hi, I'm surprised at the difference in speed/execution plan between two logically equivalent queries, one using IN, the other using EXISTS. (At least I think they are logically equivalent) I've created a small setup that illustrates what I mean. Consider the following tables: CREATE TABLE foo