Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should Data types be sizes of powers of 2 in SQL Server?

What are good sizes for data types in SQL Server? When defining columns, i see data types with sizes of 50 as one of the default sizes(eg: nvarchar(50), binary(50)). What is the significance of 50? I'm tempted to use sizes of powers of 2, is that better or just useless?

Update 1 Alright thanks for your input guys. I just wanted to know the best way of defining the size of a datatype for a column.

like image 218
burnt1ce Avatar asked Aug 26 '09 14:08

burnt1ce


2 Answers

There is no reason to use powers of 2 for performance etc. Data length should be determined by the size stored data.

like image 161
kemiller2002 Avatar answered Sep 20 '22 19:09

kemiller2002


Why not the traditional powers of 2, minus 1 such as 255...

Seriously, the length should match what you need and is suitable for your data.

Nothing else: how the client uses it, aligns to 32 bit word boundary, powers of 2, birthdays, Scorpio rising in Uranus, roll of dice...

like image 42
gbn Avatar answered Sep 18 '22 19:09

gbn