Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NVarchar(MAX) for short strings

I am interested is NVarchar(MAX) a good data type is I want to store short unicode strings which are 1-50 characters long, but most of them (more than 90%) are 5-10 characters long?

The column will not be used in comparison and ordering queries. It might be added to index as included column. Expected rows count - more than 10M.

Any recommendations? Thank you in advance!


2 Answers

Why would you use nvarchar(MAX) for such short strings? If you know the maximum length is 50 characters, make it nvarchar(50).

Also, I do not believe an nvarchar(MAX) column can be included in an index as it would break the 900 byte limit.

like image 72
DCNYAM Avatar answered Feb 28 '26 19:02

DCNYAM


I would suggest that nvarchar(50) is more appropriate if the maximum length is indeed 50.

like image 36
beach Avatar answered Feb 28 '26 17:02

beach



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!