Friday, March 9, 2012

performance on the join

I know that join on an integer field is faster than join on varchar field.
What if I cast the fields to integer within the join clause,
ex. JOIN CAST(tableA.field AS int) = CAST(tableB.field AS int)
would this speed up my query?
Thanks,
CulamNot very likely, since -- even if there are indexes on these columns -- an
explicit conversion pretty much guarantees a scan.
Did you try it? Did you compare execution plans (both real and estimated),
cpu/reads/statistics i/o, etc?
If all the data is integer, why is the column still defined as varchar?
"culam" <culam@.discussions.microsoft.com> wrote in message
news:0D47D119-344A-419E-A5EB-EA44B06F1F88@.microsoft.com...
>I know that join on an integer field is faster than join on varchar field.
> What if I cast the fields to integer within the join clause,
> ex. JOIN CAST(tableA.field AS int) = CAST(tableB.field AS int)
> would this speed up my query?
> Thanks,
> Culam
>

No comments:

Post a Comment