Are there any performance drawbacks in SQL to joining a table on a char (or varchar) value, as opposed to say joining on an integer value?
Joining on a char or var char will normally have an overhead as opposed to joining on an int. There are two factors I'm aware of when comparing chars:
- collation has to be taken account of
- char fields have more data to be compared*
*(each character is represented by 8 bits, a 10 char value is thus 80 bits long, compared to 32 bits for an int)
*(this is 16 bits per character if using NCHAR or NVARCHAR)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With