Re: ISAM calls/second
Posted in 1998
Scott Black wrote:
>
> I have the following two queries: (HP-UX 10.20, OnLine 7.22)
>
> select sum(price * quantity) expdate
> from podetail, pomaster
> where pomaster.number = podetail.number
> and expdate between "01/01/97" and "12/31/97"
> and chgcode = "5065";
>
> select sum(price * quantity) expdate_odate
> from podetail, pomaster
> where pomaster.number = podetail.number
> and expdate between "01/01/97" and "12/31/97"
> or (expdate is null
> and odate between "01/01/97" and "12/31/97")
> and chgcode = "5065";
>
> as you can see the second one is the same as the first except if expdate
> is null then drive on odate instead.
Um, I don't think so. I think what you have in the second one is:
select everything from the first one, PLUS any records where expdateis null and odate in 1997; you're missing a pair of parentheses:
select sum(price * quantity) expdate_odate
from podetail, pomaster
where pomaster.number = podetail.number
and (expdate between "01/01/97" and "12/31/97"
or (expdate is null
and odate between "01/01/97" and "12/31/97"
)
)
and chgcode = "5065";
AND has precedence over OR. Without parens, your OR will probably
cause a sequential scan. What did your set explain output say?
--
June
---- June Tong Informix Software ----
---- Senior Consultant (650) 926-6140 ----
---- International Support junet@informix.com ----
---- Location-du-jour: Menlo Park ----