Received: from candle.pha.pa.us (root@s5-03.ppp.op.net [209.152.195.67]) by hub.org (8.8.8/8.7.5) with ESMTP id VAA17035; Wed, 15 Jul 1998 21:30:41 -0400 (EDT) Received: (from maillist@localhost) by candle.pha.pa.us (8.8.5/8.8.5) id VAA08917; Wed, 15 Jul 1998 21:22:33 -0400 (EDT) From: Bruce Momjian Message-Id: <199807160122.VAA08917@candle.pha.pa.us> Subject: Re: [INTERFACES] Re: [HACKERS] changes in 6.4 In-Reply-To: <199807152339.TAA07145@candle.pha.pa.us> from Bruce Momjian at "Jul 15, 1998 7:39: 5 pm" To: maillist@candle.pha.pa.us (Bruce Momjian) Date: Wed, 15 Jul 1998 21:22:33 -0400 (EDT) Cc: daveh@insightdist.com, hannu@trust.ee, pgsql-interfaces@postgreSQL.org, hackers@postgreSQL.org X-Mailer: ELM [version 2.4ME+ PL43 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit > > The results are profound. Queries that used to scan tables because of the > OK, I have an idea. Just today, we allow: > > select * > from tab1 > where val in ( > select x from tab2 > union > select y from tab3 > ) > > How about if instead of doing: > > select * from tab1 where val = 3 > union > select * from tab1 where val = 4 > ... > > you change it to: > > select * from tab1 where val in ( > select 3 > union > select 4 > ) OK, I just ran some test, and it does not look good: --------------------------------------------------------------------------- son_db=> explain select mmatter from matter where mmatter = 'A01-001'; NOTICE: QUERY PLAN: Index Scan using i_matt2 on matter (cost=2.05 size=1 width=12) EXPLAIN son_db=> explain select mmatter from matter where mmatter in (select 'A01-001'); NOTICE: QUERY PLAN: Seq Scan on matter (cost=512.20 size=1001 width=12) SubPlan -> Result (cost=0.00 size=0 width=0) EXPLAIN --------------------------------------------------------------------------- Turns out indexes are not used in outer queries of subselects. Not sure why. Vadim? -- Bruce Momjian | 830 Blythe Avenue maillist@candle.pha.pa.us | Drexel Hill, Pennsylvania 19026 + If your life is a hard drive, | (610) 353-9879(w) + Christ can be your backup. | (610) 853-3000(h)