Search code examples
sqlentity-attribute-valuenvarchar

SQL In an EAV model, does the length of the nvarchar matter?


I'm looking to set up a Entity-Attribute-Value table model, where I want the table to handle various data. I'd like to use nvarchar(max), but I'm worried that it may affect database performance (even though most data will be under 50 chars).


Solution

  • No, in general the defined maximum length of an NVARCHAR column will not affect the performance of the database. Performance may be impacted by the amount of data actually stored in the records, but that will mostly happen if the column is indexed (which it is unlikely to be in an EAV model assuming you're talking about the Value and not the Attribute column.

    I say "in general" because you didn't specify which database you're using and it is possible to imagine some storage schemes in which the defined length does make a difference.