Re: 2 Selects 1 is faster, why?

From: Keith Gray <keith(at)heart(dot)com(dot)au>
To: Masaru Sugawara <rk73(at)sea(dot)plala(dot)or(dot)jp>
Cc: Alvar Freude <alvar(at)a-blast(dot)org>, pgsql-sql(at)postgresql(dot)org
Subject: Re: 2 Selects 1 is faster, why?
Date: 2002-06-27 23:40:46
Message-ID: 3D1BA27E.9000802@heart.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Masaru Sugawara wrote:

>
> You are right. And this type of optimising are not yet implemented.
> Tom said it in the prior discussions.
>

...but is it true that if you place the filter clause first,
the join will not have to complete the whole table?

eg.

SELECT item.description, stock.available
FROM item, stock
WHERE item.itemid = '1234'
AND item.itemid=stock.itemid;

...would be more efficient than,

SELECT item.description, stock.available
FROM item, stock
WHERE item.itemid=stock.itemid
AND item.itemid = '1234';

--
Keith Gray

Technical Services Manager
Heart Consulting Services P/L
mailto:keith(at)heart(dot)com(dot)au

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tatsuo Ishii 2002-06-28 01:46:48 Re: Slow SELECT -> Growing Database
Previous Message Vernon Wu 2002-06-27 21:47:38 Two-way query