Newsequentialid error validating default
So, here we're inserting 1 million records with their default values into 4 separate tables. This is probably the most contentious (but probably least important) issue surrounding the use of GUIDs in SQL Server, mainly because it's easy to have an opinion on it.I've written two tests for the UNIQUEIDENTIFIER data type - one to test Identity creation using NEWID() and NEWSEQUENTIALID() respectively. I've added a little bit extra formatting for clarity: Table name No. I think it's safe to say that most developers understand how basic disk allocation works - but often enterprise storage systems are a lot more complex than your developer box. INT columns have a numerical range of -2^31 to 2^31, and store only 4 bytes.Here's a list of common reasons for using a GUID in your database design: From the above, the only really acceptable scenario is no. There aren't many tables in the world that hold 9.2 quintillion records, but if you happen to have one I can guarantee that choosing a data type for its primary key is the least of your problems (and you probably won't be reading this anyway)!
In the interests of science, I'll try and keep this as factual as possible, and I'll focus on the topic at hand, rather than GUIDs / UUIDs in general.
You'll have probably noticed that My Guid is larger than My Guid Seq; this is because SQL Server tables with a clustered index are stored in the indices physical order, something which I was unaware of until I posted this stack overflow question!
I actually thought that clustered indices were a separate entity, stored along side the table.
I'm using primitive benchmarking techniques, but it still should give you a good idea of what you're up against - I will be inserting 1 million records into each table I test, and each table will have a single column with the data type and / or indices that are being tested.
First off, create a database - I've called mine "test", cos that's how I roll.I've spent many years debating with my fellow developers across all manor of subjects (I do love to talk), but one subject that comes up time and time again is the usage of the UNIQUEIDENTIFIER data type in SQL Server; especially when they're used as identity and key columns.