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 > query optimization

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-24-08, 15:15
dareman123 dareman123 is offline
Registered User
 
Join Date: Dec 2007
Posts: 30
query optimization

hi,
i ahve query taking long time to execute probably 4 mins.is there any way to improce this SQL.it using the indexes and there are no tabe scans going on. so i wonder whether or not this query could be modified to perform better.
any thoughts?..
db2 V8.2fp5 solaris

with t1 as
( SELECT TF.journ_ID,
C.NAME AS Carrier,
TS.DESCRIPTION AS journ_Status,
TF.design_DEPARTURE_TS,
TF.design_ARRIVAL_TS,
TF.ACTUAL_ARRIVAL_TS,
BR.br_id,
rtrim (udb.get_value (32, TF.journ_ID, 4964)) AS journ_Load_Type
FROM udb.journ_FACT TF
INNER JOIN udb.CARRIER_Dim C
ON TF.ACTUAL_CARRIER_ID = C.CARRIER_ID
JOIN udb.journ_STATUS_DIM TS
ON TF.journ_STATUS_ID = TS.journ_STATUS_ID
JOIN udb.cd_dt CD
ON CD.cal_DATE_KEY = design_DEPARTURE_id
AND (CD.cal_DT between '2008-01-01' And '2008-04-05')
Inner Join udb.BILL_TO_ROLE_Dim BR On TF.br_id = BR.br_id
WHERE TF.PROJECT_ID = 58
AND TF.journ_STATUS_ID NOT IN (1785630, 1241356, 7961312, 93722943)
And BR.br_id <> 15894 and
Coalesce(rtrim(udb.get_value(86, TF.journ_ID, 9119)),'mni') not in ('25')
)select * from t1

thanks in advance
Reply With Quote
  #2 (permalink)  
Old 04-25-08, 13:31
db2rocks db2rocks is offline
Registered User
 
Join Date: Jan 2008
Posts: 45
Can you post your explain plan for that query here...db2exfmt output would be better..Please attach that if you have..
Reply With Quote
  #3 (permalink)  
Old 04-26-08, 15:54
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Any reason why you put the query in a common table expression and then do a "SELECT *" from the CTE? You could just use the CTE as select statement - and "SELECT *" is bad practice anyway.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

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