View previous topic :: View next topic
|
Author |
Message |
i_suman
New User
Joined: 01 Mar 2005 Posts: 20
|
|
|
|
I want to retrieve rows that are between two dates.
I used BETWEEN for this query. Like, BETWEEN date1 AND date2. However we can also use <= and > symbols, instead.
Could some one tell which option to choose to improve the performance of the query? Is it BETWEEN or <, > symbols.
Thanks |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
You should work with your dba to determine which is best for your particular situation. |
|
Back to top |
|
|
nabarundas
New User
Joined: 21 Jun 2007 Posts: 28 Location: pune
|
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
The TS does know how to write the query...
the question is about a performance issue
case 1 ) something between limit1 and limit2
case 2 ) something > limit1 and thesamesomehing < limit2
the result set is the same, but the DB2 retrieval path might be different
full tablescan vs. index use |
|
Back to top |
|
|
nabarundas
New User
Joined: 21 Jun 2007 Posts: 28 Location: pune
|
|
|
|
I am sorry. I misjudged the question.
Regards,
Nabarun |
|
Back to top |
|
|
muthuvel
Active User
Joined: 29 Nov 2005 Posts: 217 Location: Canada
|
|
|
|
When i had the same situation of selecting the current day's inserted or updated record which was fetched by using Update Timestamp in table.
My DBA recommended BETWEEN is better than <,> for performance .
So as earler mentioned by Dick,your DBA can give you the 'best' solution than us. |
|
Back to top |
|
|
dharmendra_kp
New User
Joined: 10 Mar 2005 Posts: 33 Location: Lewiston
|
|
|
|
And DBA takes the decision based on the table structure and nature of data population. For example if that date column is part of the key and or an index is defined on that or that date column is say record update date then between will work better. If that date column is something like record insert date then most likey > < is going to be more efficient. |
|
Back to top |
|
|
Cristopher
New User
Joined: 31 Jul 2008 Posts: 53 Location: NY
|
|
Back to top |
|
|
|