Thursday, March 8, 2012

Can date ranges affect query plans?

Howdy. This seems strange to me, but maybe it is to be expected? I have two
queries that produce the same results.
When I use older date ranges(01/01/04 = 01/31/04), query 1 returns
consistently in 0-1 seconds, and query 2 returns in about 4 seconds.
But then when I use more recnt date ranges(01/01/06 - 01/31/06), I have to
cancel query 1 as it still hasnt completed after 10 minutes, while query 2
returns in about 10 seconds.
How can it be?
TIA, ChrisRWhat do the execution plans for the queries show?
SET SHOWPLAN_TEXT ON
--run your queries
Guess: Query1 will show a full table (or clustered index) scan for the date
range 1/1/06 - 1/31/06.
"ChrisR" wrote:

> Howdy. This seems strange to me, but maybe it is to be expected? I have tw
o
> queries that produce the same results.
> When I use older date ranges(01/01/04 = 01/31/04), query 1 returns
> consistently in 0-1 seconds, and query 2 returns in about 4 seconds.
> But then when I use more recnt date ranges(01/01/06 - 01/31/06), I have to
> cancel query 1 as it still hasnt completed after 10 minutes, while query 2
> returns in about 10 seconds.
> How can it be?
> TIA, ChrisR

No comments:

Post a Comment