This post compares the performance of adding an identity column to a table using Identity property versus by using sequence objects.

The below code creates a table and fills it with demo data.

The below code adds an identity column via the identity property.

1_SQL_Server_2012_Identity_VS_Sequence_A_performance_Comparison

As shown in above snapshot, it takes 8 sec to execute.

The below code creates a sequence object and adds a new column with a default property set to use the next value from the sequence object.

2_SQL_Server_2012_Identity_VS_Sequence_A_performance_Comparison

As shown above it only takes a sec to add the column which perfectly simulates the behavior of an identity column created above.

Sequence Wins !!!

 

Regards

Ahmad Osama

Like us on FaceBook Follow us on Twitter | Join the fastest growing SQL Server group on FaceBook

Follow me on TwitterFollow me on FaceBook