May 5, 2011 at 1:47 pm
Suppose TableA has 100 million rows. Is it better, from a performance standpoint, to write the query like such
select * from TableA where SomeFunction(col1)=@VariableA
or
Select * from TableA where col1 = ReverseOfSomeFunction(@VariableA)
Or does it make no difference? For Argument's sake, let's say there is a non-clustered index on col1.
I hope this makes sense
Thanks
May 5, 2011 at 3:03 pm
better:
Select * from TableA where col1 = ReverseOfSomeFunction(@VariableA)
Since the index is on col1, so it would be used and speed things up and would result in an index seek for a single value; maybe in andex scan.
if you wrap the column in a function, every row will get formatted, then compared, which requires a table scan.
Lowell
May 6, 2011 at 10:15 pm
Totally Agreed. To take advantage of index you must use "where col1 = function(@var1)".
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply