Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will joining on integer be quicker than joining on nvarchar?

Does it have a significant impact on performance if you use integer key columns instead of nvarchar(20) ? I assume that all fields used in the joins have been indexed.

like image 879
SQL Police Avatar asked Nov 06 '25 05:11

SQL Police


1 Answers

The INT should be faster than NVARCHAR(20) because an INT is only 4 bytes, so you can hold more indexes/data in memory at one time. You should always try to use the smallest data type practical for all columns.

like image 102
UnhandledExcepSean Avatar answered Nov 09 '25 08:11

UnhandledExcepSean



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!