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