October 7, 2005 at 11:19 am
Hello friend , you know, i was testing some 'selects' and i noted that the select that doesnt use a variant in the where, this is faster than one that use it , is right that?
for example select * from BigTable where name = 'Hector'
and .....................
declare @name = 'name'
select * from BigTable where name = @name
well, my query is more extense that my example, but the first is faster?
is right that? thanks to someone that could say something about that..
sorry my bad english....
October 7, 2005 at 11:33 am
did you flush the cash between each run?
October 7, 2005 at 11:33 am
Are you using a stored proc/function for this operation??
October 7, 2005 at 4:14 pm
Yep I did it i cleaned the cache
October 7, 2005 at 7:04 pm
An exact value sometimes allows the query optimizer to come up with a better plan. It knows exactly which rows match, or possibly that there are no matching rows.
With a variable it may have to use a more general plan. But you usually use variables because you don't know the value in advance, so using a constant value instead is not really an option.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply