Re: 2 Selects 1 is faster, why?

From: Alvar Freude <alvar(at)a-blast(dot)org>
To: Eric <emayo(at)pozicom(dot)net>, pgsql-sql(at)postgresql(dot)org
Subject: Re: 2 Selects 1 is faster, why?
Date: 2002-06-26 15:34:47
Message-ID: 1371510000.1025105687@gnarzelwicht.delirium-arts.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

-- Eric <emayo(at)pozicom(dot)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/

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Gunther Schadow 2002-06-26 17:54:23 Possibility of Index-Only access in PostgreSQL?
Previous Message Rajesh Kumar Mallah. 2002-06-26 15:18:05 Re: sequence chages after firing update