Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 32519475C29 for ; Wed, 26 Jun 2002 12:33:46 -0400 (EDT) Mailbox-Line: From alvar@a-blast.org Wed Jun 26 12:33:46 2002 Received: from gnarzelwicht.delirium-arts.de (mail.delirium-arts.de [195.143.204.190]) by postgresql.org (Postfix) with ESMTP id C9796475C29 for ; Wed, 26 Jun 2002 11:34:43 -0400 (EDT) Received: from gnarzelwicht.delirium-arts.de (gnarzelwicht.delirium-arts.de [195.143.204.190]) by gnarzelwicht.delirium-arts.de (Postfix) with ESMTP id 12DDF60E60; Wed, 26 Jun 2002 17:34:48 +0200 (CEST) Date: Wed, 26 Jun 2002 17:34:47 +0200 From: Alvar Freude To: Eric , pgsql-sql@postgresql.org Subject: Re: 2 Selects 1 is faster, why? Message-ID: <1371510000.1025105687@gnarzelwicht.delirium-arts.de> In-Reply-To: References: X-Mailer: Mulberry/2.2.1 (Linux/x86) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Spam-Status: No, hits=-3.5 required=5.0 tests=IN_REP_TO,SUBJ_ENDS_IN_Q_MARK version=2.30 X-Spam-Level: X-Archive-Number: 200206/353 X-Sequence-Number: 8318 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. Explizit joins should speed up this! > NOTE: The actual queries return more information than this, but the > fundamental change shown above seems to give me the instant response I am > looking for. (1) takes about 60 seconds to run and (2) takes 3-5 seconds > to run. 3-5 seconds seems very long to me, if indexes are used and the result is not a set of thousands of rows; are you sure? Ciao Alvar -- // Unterschreiben! http://www.odem.org/informationsfreiheit/ // Internet am Telefon: http://www.teletrust.info/ // Das freieste Medium? http://www.odem.org/insert_coin/ // Blaster: http://www.assoziations-blaster.de/