Re: 2 Selects 1 is faster, why?
Alvar Freude <alvar@a-blast.org>
From: Alvar Freude <alvar@a-blast.org>
To: Eric <emayo@pozicom.net>, pgsql-sql@postgresql.org
Date: 2002-06-26T15:34:47Z
Lists: pgsql-sql
Hi, -- Eric <emayo@pozicom.net> 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/