Re: IN(subselect returning few values ...)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: IN(subselect returning few values ...)
Date: 2006-11-01 20:11:06
Message-ID: 25096.1162411866@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Stephen Frost <sfrost(at)snowman(dot)net> writes:
> Working on 8.1 I've recently been annoyed at the need to translate a
> sub-select inside an IN () clause into a fixed list of contents (the
> results of the sub-select, exactly) in order to get better performance.

Better performance than what? Ever since 7.4 we've converted small IN
sub-selects into plans along the lines of

regression=# explain select * from tenk1 where unique1 in (select f1 from int4_tbl);
QUERY PLAN
-----------------------------------------------------------------------------------
Nested Loop (cost=1.06..31.20 rows=5 width=244)
-> HashAggregate (cost=1.06..1.11 rows=5 width=4)
-> Seq Scan on int4_tbl (cost=0.00..1.05 rows=5 width=4)
-> Index Scan using tenk1_unique1 on tenk1 (cost=0.00..6.00 rows=1 width=244)
Index Cond: (tenk1.unique1 = "outer".f1)
(5 rows)

which looks OK to me.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message JEAN-PIERRE PELLETIER 2006-11-01 20:29:33 Index ignored with "is not distinct from", 8.2 beta2
Previous Message Martijn van Oosterhout 2006-11-01 19:59:00 Re: ¿¿¿pas