Wednesday, July 13, 2011

Remembering the COMBGuids

The new SQL Server 2005+ NewSequentialID() function is great because you can use GUIDs for primary key's without suffering the the query performance hit normally associated with using random values for primary keys due to ordering in tables. But...you have to create these NewSequentialID's on the SQL side of things, which means that you have to pass them back to your web application, and sometimes that is problematic. It is much easier to create a GUID on the Web side of things before doing the insert, so that you have the key on the web side to access the just inserted data without having to have that key generated and then passed back to you.

For some of you what I'm saying will make absolutely no sense. For others, you see where I'm going. But with a technique known as COMBGuids, you can create sequential GUIDs for IDs on the web side and then pass them into your database.

Here is an implementation of COMBGuids that I've used in the past.

No comments: