I have the following querys:
SELECT ID, ADDRESS
FROM EMPLOYEE A
WHERE ID=12345
AND CURRENT DATE BETWEEN A.EFF_DT AND A.EXP_DT
SELECT ID, ADDRESS
FROM EMPLOYEE A
WHERE ID=12345
AND CURRENT DATE >= A.EFF_DT AND CURRENT DATE <= A.EXP_DT
Out of these two queries which query yields better performance.
Here I am using operators >= and <= instead of BETWEEN.
Please suggest.
Thanks in advance.
Both those should give you exactly the same execution profile, based on my knowledge of DB2/z (the LUW product may be different but I doubt it).
If you're really concerned, you should run an EXPLAIN on the two queries to see if there are any differences.
Between is simply a shorthand for >= and <= ,
if want find more help go to the link is here: Is the 'BETWEEN' function very expensive in SQL Server?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With