1

I have a table that has a uniqueidentifier column only used by some of the rows.

Is it a good idea to:

  • make that column nullable and make unused rows' uniqueidentifier null?
  • or not make the column nullable and fill in a GUID value for all rows?

Will there be any performance difference with SELECT queries on the uniqueidentifier column? And what about disk space? Do null values take up the same amount of space?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
James
  • 2,811
  • 3
  • 25
  • 29

2 Answers2

7

If you are on SQL Server 2008+, you might want to look into using sparse columns. It is optimized for storing a column that contains mostly null values.

d89761
  • 1,434
  • 9
  • 11
0

Also check MSSQL filtered indexes if you are going to use nullable columns in where clauses.