By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,326 Members | 2,726 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,326 IT Pros & Developers. It's quick & easy.

DB2 timestamp query - Query optimization

P: 1
Hi All,

My requirement is to fetch the previous day records.Iam joining three tables hereby.I used the below queries,but the DB2 cost seems to be high.Is there any simpler way to reduce the db2 cost and optimize the query further?

Query:
-----
Iam selecting around ten fields and below is my where condition,

Query:1
--------

Expand|Select|Wrap|Line Numbers
  1. FROM     ARJ00T.ARJAUTH A, ARJ00T.ARJCUST B, ARJ00T.ARJCMNT C 
  2. WHERE    DATE(C.CRTN_TS) = DATE(CURRENT TIMESTAMP - 1 DAYS)      
  3.   AND    A.AUTH_RFRNC_NO = B.AUTH_RFRNC_NO                       
  4.   AND    A.AUTH_RFRNC_NO = C.RFRNC_NO                            
  5.   AND    A.LOB_C = 'CCDO'                                        
  6.   AND    A.PROD_CODE = 'PPC'                                     
  7.   AND    B.CUST_TP_C = 'IND'                                     
  8. WITH     UR           
Query:2
-------

Expand|Select|Wrap|Line Numbers
  1. WHERE C.CRTN_TS BETWEEN TIMESTAMP(CURRENT_DATE - 1 DAY) 
  2. AND   TIMESTAMP(CURRENT_DATE - 1 DAY) + 86399 SECONDS
Feb 13 '14 #1
Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,359
Please use code tags when posting code or formatted data.

That's a pretty simple query unless you're doing something complicated in the SELECT clause that you're not showing us. The only optimizations you can do is putting on the proper indexes.
Feb 14 '14 #2

Post your reply

Sign in to post your reply or Sign up for a free account.