Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 5F1334772B5 for ; Thu, 27 Jun 2002 12:04:22 -0400 (EDT) Mailbox-Line: From rk73@sea.plala.or.jp Thu Jun 27 12:04:22 2002 Received: from mps2.plala.or.jp (mpsb-nat02.plala.or.jp [202.212.114.145]) by postgresql.org (Postfix) with ESMTP id 8371847717C for ; Thu, 27 Jun 2002 11:03:27 -0400 (EDT) Received: from vip1600 ([218.47.117.7]) by mps2.plala.or.jp with ESMTP id <20020627150330.JSVC25092.mps2.plala.or.jp@vip1600>; Fri, 28 Jun 2002 00:03:30 +0900 Date: Fri, 28 Jun 2002 00:04:07 +0900 From: Masaru Sugawara To: Alvar Freude Subject: Re: 2 Selects 1 is faster, why? Cc: pgsql-sql@postgresql.org In-Reply-To: <1371510000.1025105687@gnarzelwicht.delirium-arts.de> References: <1371510000.1025105687@gnarzelwicht.delirium-arts.de> Errors-To: rk73@sea.plala.or.jp Message-Id: <20020627234531.7ECB.RK73@sea.plala.or.jp> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Becky! ver. 2.00.11 X-Spam-Status: No, hits=-3.1 required=5.0 tests=IN_REP_TO,SUBJ_ENDS_IN_Q_MARK,FROM_ENDS_IN_NUMS version=2.30 X-Spam-Level: X-Archive-Number: 200206/365 X-Sequence-Number: 8330 On Wed, 26 Jun 2002 17:34:47 +0200 Alvar Freude wrote: > Hi, > > -- Eric wrote: > > > If I perform the following 2 selects, the first one is EXTREMELY slow > > where the 2nd one is very fast. > > [...] > > > Why would 2 be so much faster? I have ran the EXPLAIN on this and index > > scans are being used. > > I guess, the first query has to search for all ol.orderid the equivalent > o.orderid; the second variant only has to search for '1234' in each > ?.orderid, which is much faster. You are right. And this type of optimising are not yet implemented. Tom said it in the prior discussions. Regards, Masaru Sugawara