I have an existing table and once I add an ObjectId
UniqueIdentifier
column with default NewSequentialId()
value, the data space suddenly doubles. I'm using the script below:
ALTER TABLE Employee
ADD ObjectId uniqueidentifier constraint Employee_ObjectId
default(newsequentialid()) not null
For example, if I have currently 3MB of data space used, with 23k records, and execute the above script, suddenly it becomes almost 6MB of data space.
My objective here is to learn the reason why this is happening, because I imagine if there are millions of records, this will consume too much storage space after.
The original script was using newid()
instead of newsequentialid()
. Found some info regarding fragmentation when using newid()
, so I replaced that. But other than that I'm at lost here.
Employee Table
Id (PK, bigint, not null)
InfoA (nvarchar(4000), null)
InfoB (numeric(28,9), null)
Company (FK, bigint, not null)
Index: 1 Clustered index (PK) and 2 Non-unique non-clustered index