Hello Friends , i have a thought about the query , but i need your confirmation please.

  • 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....

     

     

  • did you flush the cash between each run?

  • Are you using a stored proc/function for this operation??

  • Yep I did it i cleaned the cache

  • 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