Groups | Blog | Home
all groups > sql server replication > december 2006 >

sql server replication : Identity crisis: GUID VS. Range



jordics NO[at]SPAM gmail.com
12/20/2006 6:52:38 AM
Hi!

I'm developing a project in which I have several Sql Server Express and
Sql Server Mobile 2005 databases and all of them are subscribed to a
central Sql Server 2005 database.

Now, I'm in trouble with the primary keys because if i insert two
registers with the same primary key in two different subscribers, when
the record is merged to the publisher, there is a primary key
collision.

I'm studying two different solutions:

A) Assign ranges of primary keys in each subscriber in order to assign
different IDs in each subscriber
B) User GUID as primary keys, so each primary key will be diferent.

Which are the pros and cons of each solution? Do you think one is best
than the other? Will I have performance problems using GUIDs in a Sql
Server Mobile database?

Thaks in advance!


Jordi
Hilary Cotter
12/20/2006 3:31:56 PM
Guid's don't perform as well as int identity. If you use the
newsequentialid() property you will get sequential guids but although
fragmentation is reduced you still don't get the performance of a int data
type.

Your choices are to extend your primary key to include a location identifier
or implement automatic identity range management.
--
Hilary Cotter

Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html

Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com



[quoted text, click to view]

Josep
12/20/2006 7:11:02 PM
Hi,

There's a really good article about Identities, written by Hilary Cotter:
http://www.simple-talk.com/sql/database-administration/the-identity-crisis-in-replication/

I'm using SQL Server automatic identity ranges. It works fine, at least for
me.

Performance problems? Well, I think this depends quite a lot in your
database design but the GUID is much bigger than an integer type and if it's
the primary key then the index can grow a lot.
and if you are just starting now the development or if you have all done and
you want to replicate now...


Josep.

PS: Ja m'explicaràs què tal...


<jordics@gmail.com> escribió en el mensaje
news:1166626358.727257.205170@t46g2000cwa.googlegroups.com...
[quoted text, click to view]

AddThis Social Bookmark Button