2 Selects 1 is faster, why?

Поиск
Список
Период
Сортировка
От Eric
Тема 2 Selects 1 is faster, why?
Дата
Msg-id afag3c$kce$1@news.hub.org
обсуждение исходный текст
Ответы Re: 2 Selects 1 is faster, why?  (Alvar Freude <alvar@a-blast.org>)
Список pgsql-sql
If I perform the following 2 selects, the first one is EXTREMELY slow where
the 2nd one is very fast.

(1) Slow

select o.orderid, ol.itemcode, ol.itemname

from orders o, orlines ol

where o.orderid = '1234' and ol.orderid = o.orderid;

(2) VERY FAST

select o.orderid, ol.itemcode, ol.itemname

from orders o, orlines ol

where o.orderid = '1234' and ol.orderid = '1234'

Why would 2 be so much faster?  I have ran the EXPLAIN on this and index
scans are being used.

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.

Thanks, Eric






В списке pgsql-sql по дате отправления:

Предыдущее
От: "Ian Cass"
Дата:
Сообщение: Quickest way to insert unique records?
Следующее
От: "Eric"
Дата:
Сообщение: Performance Ideas