If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Help improving Select command.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-18-10, 12:34
prado prado is offline
Registered User
 
Join Date: Nov 2010
Posts: 1
Question Help improving Select command.

Hello guys,

I have this query, and its taking over 25 min to return the results, I know its somehow a complex query and most of the tables it looks in has over 500K rows, in exception of ops.xml_count that has arround 250 rows

here it is.

select distinct T2.VALFROM,T2****NTIME,
(select count(valfrom) as GBLI_COLLATERAL from GBLI.COLLATERAL where valfrom between (T2.VALFROM) and (T2****NTIME)),
(select count(valfrom) as GBLI_COMPONENTGROUP from GBLI.COMPONENTGROUP where valfrom between (T2.VALFROM) and (T2****NTIME)),
(select count(valfrom) as GBLI_FEATUREDETAIL from GBLI.FEATUREDETAIL where valfrom between (T2.VALFROM) and (T2****NTIME)),
(select count(valfrom) as GBLI_PRODSTRUCT from GBLI.PRODSTRUCT where valfrom between (T2.VALFROM) and (T2****NTIME)),
(select count(valfrom) as GBLI_PRODFLAG from GBLI.PRODFLAG where valfrom between (T2.VALFROM) and (T2****NTIME)),
(select count(valfrom) as GBLI_WWATTRIBUTES from GBLI.WWATTRIBUTES where valfrom between (T2.VALFROM) and (T2****NTIME)),
(select count(valfrom) as GBLI_WWCOMPONENTS from GBLI.WWCOMPONENTS where valfrom between (T2.VALFROM) and (T2****NTIME)),
(select count(valfrom) as GBLI_WWPRODUCT from GBLI.WWPRODUCT where valfrom between (T2.VALFROM) and (T2****NTIME)),
(select count(countrycode) as EACM_FINALPRICE from EACM.FINALPRICE where lastupdated between (T2.VALFROM) and (T2****NTIME)),
(select count(country) as EACM_FINAL_CATPRODREL from EACM.FINAL_CATPRODREL where valfrom between (T2.VALFROM) and (T2****NTIME)),
(select count(country) as EACM_FINAL_COMPAT from EACM.FINAL_COMPAT where valfrom between (T2.VALFROM) and (T2****NTIME)),
(select count(nlsid) as EACM_FINAL_FEATURE from EACM.FINAL_FEATURE where valfrom between (T2.VALFROM) and (T2****NTIME)),
(select count(valfrom) as EACM_FINAL_PRODUCT from eacm.FINAL_PRODUCT where valfrom between (T2.VALFROM) and (T2****NTIME)),
(select count(valfrom) as EACM_FINAL_PRODPRODREL from eacm.FINAL_PRODPRODREL where valfrom between (T2.VALFROM) and (T2****NTIME)),
(select count(valfrom) as EACM_FINAL_WWATTRVALUE from EACM.FINAL_WWATTRVALUE where valfrom between (T2.VALFROM) and (T2****NTIME)),
(select count(valfrom) as EACM_FINAL_WWCOMPAT from EACM.FINAL_WWCOMPAT where valfrom between (T2.VALFROM) and (T2****NTIME)),
(select count(valfrom) as EACM_FINAL_WWPRODPRODREL from EACM.FINAL_WWPRODPRODREL where valfrom between (T2.VALFROM) and (T2****NTIME))

from ops.xml_count T2 with ur

Last edited by prado; 11-18-10 at 13:01.
Reply With Quote
  #2 (permalink)  
Old 11-18-10, 16:03
dav1mo dav1mo is offline
Registered User
 
Join Date: Dec 2007
Location: Richmond, VA
Posts: 782
What are your counts like, how much data are you counting? Do you have indexes on all of these tables to support the WHERE clause, meaning an index on VALFROM and a couple of them with valfrom, country or valfrom, nlsid or lastupdated, countrycode?

Dave Nance
Reply With Quote
Reply

Tags
complex, improve, tuning

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On