|
The following SQL statement runs in maybe 25 seconds in iSQL (V5R2, of course,
current PTFs) but a batch run as embedded SQL it takes a couple hours:
select
FLD001 ,
FLD002 ,
FLD003 ,
FLD004 ,
sum(
(A.FLD005-FLD006)
* (FLD007/A.FLD005)
)
as TOT ,
FLD008 ,
PERIOD
from (
select
case
when FLD009 < 1040401 [:h1] then '1'
when FLD009 > 1040601 [:h2] then '4'
when FLD009 >= 1040501 [:h3] then '3'
else '2'
end
as PERIOD ,
FLD001 ,
FLD002 ,
FLD003 ,
FLD004 ,
FLD009 ,
FLD005 ,
FLD006 ,
FLD007 ,
FLD008
from
TBL01 a ,
TBL02 b
where
a.FLD001 in ('FL' , '00') and
a.FLD005 <> 0 and
A.FLD010 = ' ' and
a.FLD001 = b.FLD011 and
a.FLD012 = b.FLD013 and
exists(
select
*
from
TBL03 c
where
a.FLD001 = c.FLD014 and
a.FLD015 = c.FLD016 and
c.FLD017 <> 'Q' and
c.FLD018 in ('CC','CL ,'CP','CS','CU')
)
) as A
group by
FLD001 ,
FLD002 ,
FLD003 ,
FLD004 ,
FLD008 ,
PERIOD
The [:hn] elements in the CASE clause simply mean the values are supplied by
host variables. Regardless of whether proper indexes are available, what
elements would cause such a major difference in run-time between environments?
Run priority of interactive vs. batch is certainly possible, but the
interactive is also during busy working hours and batch is at night during
relatively quiet periods. Memory pools seem appropriate (approx 500MB for both
batch and interactive during run periods).
At the moment, it's not a question of whether the statement could be better
constructed. It's a question of curiosity about the difference.
Thanks for any discussion.
Tom Liotta
__________________________________________________________________
Introducing the New Netscape Internet Service.
Only $9.95 a month -- Sign up today at http://isp.netscape.com/register
Netscape. Just the Net You Need.
New! Netscape Toolbar for Internet Explorer
Search from anywhere on the Web and block those annoying pop-ups.
Download now at http://channels.netscape.com/ns/search/install.jsp
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.