Re: 2 Selects 1 is faster, why? - Mailing list pgsql-sql

From Alvar Freude
Subject Re: 2 Selects 1 is faster, why?
Date
Msg-id 1371510000.1025105687@gnarzelwicht.delirium-arts.de
Whole thread Raw
In response to 2 Selects 1 is faster, why?  ("Eric" <emayo@pozicom.net>)
Responses Re: 2 Selects 1 is faster, why?  (Masaru Sugawara <rk73@sea.plala.or.jp>)
List 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/





pgsql-sql by date:

Previous
From: "Rajesh Kumar Mallah."
Date:
Subject: Re: sequence chages after firing update
Next
From: Gunther Schadow
Date:
Subject: Possibility of Index-Only access in PostgreSQL?