473,326 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

DB2 timestamp query - Query optimization

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
1 1778
Rabbit
12,516 Expert Mod 8TB
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

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

Similar topics

1
by: NDS Ltd | last post by:
hi, someone on this group made me a query which worked a treat. i have tried changing it but instead of returning the expected 700 records it returns half a million.. with lots of duplicates. ...
1
by: Chris Hall | last post by:
Hello, I am having a problem writing an SQL query. The tables I have are History id transaction_id state_id 1 1 ...
6
by: Toucan | last post by:
i need to retrieve the most recent timestamped records with unique names (see working query below) what i'm having trouble with is returning the next-most-recent records (records w/ id 1 and 3...
2
by: David Gordon | last post by:
Hi Folks, I wonder if anyone can help me with the following (perhaps trivial) problem: <xml> <node name="a" type="a"/> <node name="b" type=""/> <node name="c"/> <node name="d" type="b"/>...
16
by: Brian Tkatch | last post by:
I have a PROCEDURE that test other PROCEDUREs. Timings_Call ------------------ Id Group Name Text Timings_Log
3
by: Mike Charney | last post by:
I have a two part question: First I want to insert data into a table and I am using the following command: INSERT INTO tblmain SELECT field1, field2, etc... FROM tblimport WHERE ?????? The...
0
by: rjy24 | last post by:
Hi, I am facing problem with the following query .It is taking a lot of execution time.I need help with tuning this query. Query: SELECT A, B, C,
1
by: babamc4 | last post by:
Hi All, I am trying to run a query to include null fields. My tables are as follows: Table Demographics 54 records (Main table) Table Follow Up During Radiotherapy 100+ records (Sub table)...
0
by: richdyer_2000 | last post by:
I'm new to Access (and databases in general) and have the following problem.... TABLE_A is basically just a list of events occurring on a system. It has fields; "EVENT_ID" (auto number),...
3
by: srbakshi | last post by:
Hi all! I have a txt file that has some strings in the following format: TAG=MyString Eg: FRUIT=I like mangoes CARS=I like red cars . . .
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.