IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Which is better performance.....Between or Equal


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ramfrom84

New User


Joined: 23 Aug 2006
Posts: 93
Location: chennai

PostPosted: Thu Jun 28, 2007 7:05 pm
Reply with quote

Hi All,

I have Db2 related job to be run for daily and also Monthly, i m using Cursor with date as condition, Which is Better Between ort Equal

Consider the performance of 1 & 2 ,

1.If i use same cursor for both Daily and Monthly with date field as Condition as below ..

Date between Start_date and End_date.

for Daily, i m moving same date to Start and End Date ,
For Month i moved 01 to start_date and Job run at last day of the month so i moved date to End Date.
EX:
Daily
Date between '2007-06-28' and '2007-06-28'
Monthly
Date between '2007-06-01' and '2007-06-30'


2 . Alternate option :
Two Cursor one for daily and other one for Monthly job as mention below

Daily Cursor should have

Date = WS_date

Monthly Curosr as

Date between Start_date and End_date.

Daily :
Date = '2007-06-28'

Monthly
Date between '2007-06-01' and '2007-06-30'


bye....
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Jun 28, 2007 7:54 pm
Reply with quote

Hello,

Long ago the equals would (always?) perform better than the between.

As the query optomizer is improved, it may recognize the values named in the between as being a single value, and process just as efficiently as the equals.

You could talk with your dbas to set up a performance test to see how this compares on your system.
Back to top
View user's profile Send private message
TG Murphy

Active User


Joined: 23 Mar 2007
Posts: 148
Location: Ottawa Canada

PostPosted: Thu Jun 28, 2007 11:50 pm
Reply with quote

Setup yourself up with 2 SQLs. One uses BETWEEN. The other uses =.

1. Feed both SQLs into the EXPLAIN utility and observe the cost estimate from EXPLAIN.

2. Run both SQLs and ask the DBA to do a DB2 trace. The trace will tell you how much CPU the statements chew up.

3. Create your own benchmark program that executes both SQLs. Execute both SQLs many times. For example:

PERFORM SQL1 1000 TIMES
PERFORM SQL2 1000 TIMES
PERFORM SQL1 1000 TIMES
PERFORM SQL2 1000 TIMES

Within each section use SET CURRENT TIMESTAMP to measure and display the elapsed time. Compare.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Jun 29, 2007 12:57 am
Reply with quote

You allso have to consider maintenance -- with one option you have 1 cursor and 1 fetch in the program with the other you have 2 cursors and 2 fetches and the logic to decide which one get used when.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts exploiting Z16 performance PL/I & Assembler 2
No new posts JOIN STATEMENT PERFORMANCE. DFSORT/ICETOOL 12
No new posts check if two PD values are equal, no ... DFSORT/ICETOOL 4
No new posts Which SORT utility can improve the Pe... DFSORT/ICETOOL 16
No new posts COBOL Performance Tuning COBOL Programming 6
Search our Forums:

Back to Top