Menu

Programming with Palermo

Jeffrey Palermo, Microsoft MVP, Author, Speaker, Clear Measure Chief Architect, Azure DevOps Expert

Skip to content
  • Home
  • Blog
  • About Jeffrey Palermo
  • Onion Architecture
  • Clear Measure, Inc.
  • .NET DevOps for Azure

Jeffrey Palermo 12:09 am on August 20, 2006
Tags: Data Access ( 6 ), Tips & Tricks ( 43 )   

Use guid.comb in your database if you need guid keys but don’t want to take a big performance hit – level 300

See http://jeffreypalermo.com/blog/use-guid-comb-in-your-database-if-you-need-guid-keys-but-don-t-want-to-take-a-big-performance-hit/ for this article.

Related

  1. Jon Galloway 1:48 am on August 20, 2006

    Another option (in Sql Server 2005) is NEWSEQUENTIALID(), which generates a GUID which is greater than any previous GUID on that computer. If you set NEWSEQUENTIALID() as the default on a PK GUID column, you’ll avoid the fragmentation problem.

    http://msdn2.microsoft.com/en-us/library/ms189786.aspx

  2. Melvin Lee 11:11 am on August 20, 2006

    Hi Jeffrey,

    Can you tell me for what situations have you used (comb) guids? I had a situation at a customer where the customer have several applications that share part of the database schema, but not the database instance. One application will aggregate through all the database instances and display the data as it is from one database. My solution was to use guids so that I don’t have to assign ranges to applications. This is the only situation I can think of why I should use guids.

  3. C-J Berg 3:12 pm on August 20, 2006

    Melvin Lee: Yes, you would want to use it to ease replication scenarios.

    As Jon wrote, there’s a new function in SQL Server 2005 that does exactly this, NewSequentialID. Just be sure to read the following notes on the subject:

    http://blogs.msdn.com/sqlprogrammability/archive/2006/03/23/559061.aspx

  4. Melvin Lee 7:30 pm on August 21, 2006

    C-J,

    I understand why you should use comb guids. But what I’m actually looking for are scenarios where I should use guids instead of plain integers for surrogate keys. Other than the scenario I have described I can’t think of another situation where I would use guids as keys

  5. ScottBellware 4:15 am on August 22, 2006

    I typically prefer GUIDs for ID’s in place of integers if the integer ID’s have to be generated by a database server.

    I’ve never really been comfortable with the idea that an abstraction like a business object – something that can be used for more than persistence to the application’s database – must get it’s ID from an external, and very likely, distributed system. Since a GUID’s uniqueness is ensured algorithmically, and since it can be done in the same local memory space as the object that it identifies, it seems a bit off to me that we’d defer to a remote dependency for something that is easily had locally, and that can be kept close to the object that is its primary client, and that is most concerned with it.

    Since SQL Server 2005 has addressed the index fragmentation issue with GUID-based indexes, and since the COMB GUID generation code is easily had, GUIDs are a much easier decision to make.

    That said, there are still compelling reasons to use integer ID’s, but the vast majority of database apps aren’t of the ilk that require integer ID’s specifically.

Comments are closed.

Post navigation

← If it takes forever to start your app with the debugger, check for thrown exceptions – level 300
How to produce a software product quickly, part 1 – level 300 →
  • RSS - Posts

Subscribe to Blog

Jeffrey Palermo

Jeffrey Palermo

View Full Profile →

Tags

Agile alt.net altnetconf ASP.NET asp.net mvc aspnetmvc aspnetmvc mvc asp.net palermo Build Automation clear measure Coding Principles Data Access Developer Community devops Featured FIT Learning Managing mvc onion architecture partywithpalermo Party with Palermo Services teched teched2008 nhibernate aspnetmvc orm scm Tips & Tricks Tools

Archives

  • January 2020
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • November 2016
  • April 2016
  • November 2015
  • August 2015
  • June 2015
  • November 2014
  • October 2014
  • September 2014
  • August 2014
  • June 2014
  • May 2014
  • February 2014
  • January 2014
  • December 2013
  • August 2013
  • July 2013
  • June 2013
  • May 2013
  • April 2013
  • March 2013
  • February 2013
  • January 2013
  • February 2012
  • November 2011
  • October 2011
  • September 2011
  • July 2011
  • May 2011
  • April 2011
  • March 2011
  • February 2011
  • January 2011
  • December 2010
  • November 2010
  • September 2010
  • August 2010
  • May 2010
  • April 2010
  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • September 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • February 2009
  • January 2009
  • December 2008
  • November 2008
  • October 2008
  • September 2008
  • August 2008
  • July 2008
  • June 2008
  • May 2008
  • April 2008
  • March 2008
  • February 2008
  • January 2008
  • December 2007
  • November 2007
  • October 2007
  • September 2007
  • August 2007
  • July 2007
  • June 2007
  • May 2007
  • April 2007
  • March 2007
  • February 2007
  • January 2007
  • December 2006
  • November 2006
  • October 2006
  • September 2006
  • August 2006
  • July 2006
  • June 2006
  • May 2006
  • April 2006
  • March 2006
  • February 2006
  • January 2006
  • December 2005
  • November 2005
  • October 2005
  • September 2005
  • August 2005
  • July 2005
  • June 2005
  • May 2005
  • April 2005
  • March 2005
  • February 2005
  • January 2005
  • December 2004
  • November 2004
  • October 2004
  • September 2004
  • August 2004
  • July 2004
  • June 2004
  • May 2004
  • April 2004
Proudly powered by WordPress | Theme: P2 by WordPress.com.