Sql Server int vs nvarchar comparison on performance? -


The database design / performance guru for you are out there.

I am designing a table, I either use the int or naratrat (128) for any column, assuming the place is not a problem. My question is that

returns to the display

where id = 12324

or when I search the Nvarchar column (the key is complete Price, so I'm not using the preferred operator)

where key = 'my str'

I'm definitely small datasets It does not matter, but assume that this data will be in millions of rows.

INT will be fast - here's why:

  • 8k < SQL Server organizes your data and index in the pages of
  • If you have an index page with the INT key, if you have NVRAR (128) and you use the average 20 characters, then This is 40 bytes per entry or about 200 entries per page
You get approximately 2'000inent entries
  • e For the same amount of index entries, Anviaraaraar (128) will be used ten times index pages in the case.

    There will be a lot of IOO operations to load and search those index pages.

    So to reduce things: If you can, always use INT.


  • Comments