By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,870 Members | 1,224 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,870 IT Pros & Developers. It's quick & easy.

Is a GUID always unique?

P: n/a
Greetings All, I have read many upon many articles here regarding GUID
data types and uniqueness. There have been many opinions regarding
the effectiveness of GUID's and when they should/should not be used.
However, every article strongly implies, if it does not state it
outright, that GUID's are always unique. My question is this, what
happens if you have a database that uses GUID's and the NIC is changed
out on the box? From what I understand the MAC address of the NIC is
used as part of the algorithm to generate a GUID. If you change out
the NIC after generating 1 billion GUID's do you run the chance of
generating a duplicate GUID?

I look forward to your insightfulness on this issue.

Regards, Louis.
Jul 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Louis Frolio" :
Greetings All, I have read many upon many articles here regarding GUID
data types and uniqueness. There have been many opinions regarding
the effectiveness of GUID's and when they should/should not be used.
However, every article strongly implies, if it does not state it
outright, that GUID's are always unique. My question is this, what
happens if you have a database that uses GUID's and the NIC is changed
out on the box? From what I understand the MAC address of the NIC is
used as part of the algorithm to generate a GUID. If you change out
the NIC after generating 1 billion GUID's do you run the chance of
generating a duplicate GUID?

I look forward to your insightfulness on this issue.

Regards, Louis.


Louis,

Assuming the RPC and COM implementation for GUID creation on Windows (and I
assume that's what SQL Server uses as well, but I'm not sure), then a GUID
is virtually guaranteed to be unique even if you switch MAC addresses (by
switching cards or changing it in software if the network card supports that
feature). Computers without network cards are guaranteed to generate unique
GUID on that computer but in practice are still pretty good at generating
completely unique GUID's.

I think you'll find that most articles (especially those written by people
with training in Computer Science or Software Engineering) will skirt the
issue because I don't think there's an algorithm that can formally guarantee
universal unqiueness. (If there is someone *please* correct me: I'd love to
know what it is!)

But... keep in mind that a GUID is 128 bits. If you assume that 64 bits
will be used as a system identifier (like a MAC address), you would still
need more than a quadrillion GUID's before you started approaching the realm
of likely duplication. For some really crazy numbers: assume 1,000,000
computers generating a 1,000,000 GUID's a day. In a thousand years, you
would have used up around 2% of the "number space" in 64 bits. (Of course,
this is a specious example since we conveniently ignored the algorithmic
difficulty of "divying up" the range of numbers possible in 64 bits, but
it's still a cool number :)

That's why GUID's really shine in distributed environments: any computer can
generate as many unique identifiers as required. We use them for a system
we have where a client must create an "entity" that when mapped to our
relational schema could be hundreds of rows across multiple tables. And for
reasons I won't go into, the client must be able to reliably create the
entire entity before ever connecting to a server. Without GUID's (or
something similar) we'd need to something much more painful which would
probably end emulating the MS GUID algorithm anyway.

The point of the above? After millions of these "entities" and hundreds
(possibly thousands) of GUID's for COM components, we've never had a
collision. And that includes computers that have changed Ethernet cards 3
or 4 times, computers that were operated with no network adapter installed
for a week at a time, and computers with multiple adapters. And in our
initial testing for the system 3 or so years ago, we generated 500 million
GUIDS from a single computer and never had a collision.

The bottom line and my $0.02? If you decide to go with GUID's, of course
use constraints in the database like you would for any other column that is
supposed to be unique or a foreign key or whatever, but if an error is ever
detected, look for software bugs waayyyyyy before suspecting duplicate GUID
creation.

Craig
Jul 20 '05 #2

P: n/a
Louis Frolio (fr*****@yahoo.com) writes:
Greetings All, I have read many upon many articles here regarding GUID
data types and uniqueness. There have been many opinions regarding
the effectiveness of GUID's and when they should/should not be used.
However, every article strongly implies, if it does not state it
outright, that GUID's are always unique. My question is this, what
happens if you have a database that uses GUID's and the NIC is changed
out on the box? From what I understand the MAC address of the NIC is
used as part of the algorithm to generate a GUID. If you change out
the NIC after generating 1 billion GUID's do you run the chance of
generating a duplicate GUID?


The MAC address thing only concerns NT4. On Win2000 and later it is
completely random.

And 1 billion is a whole lot. Even if you would happen to mean 1
milliard it is a whole lot. Even if you get 100000 orders a day, it
takes 27 years before you have a milliard of them. For a billion
orders that's 27000 years...

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #3

P: n/a
"Craig Kelly" <cn************@nospam.net> wrote in message news:<Sh*********************@bgtnsc05-news.ops.worldnet.att.net>...
"Louis Frolio" :
Greetings All, I have read many upon many articles here regarding GUID
data types and uniqueness. There have been many opinions regarding
the effectiveness of GUID's and when they should/should not be used.
However, every article strongly implies, if it does not state it
outright, that GUID's are always unique. My question is this, what
happens if you have a database that uses GUID's and the NIC is changed
out on the box? From what I understand the MAC address of the NIC is
used as part of the algorithm to generate a GUID. If you change out
the NIC after generating 1 billion GUID's do you run the chance of
generating a duplicate GUID?

I look forward to your insightfulness on this issue.

Regards, Louis.


Louis,

Assuming the RPC and COM implementation for GUID creation on Windows (and I
assume that's what SQL Server uses as well, but I'm not sure), then a GUID
is virtually guaranteed to be unique even if you switch MAC addresses (by
switching cards or changing it in software if the network card supports that
feature). Computers without network cards are guaranteed to generate unique
GUID on that computer but in practice are still pretty good at generating
completely unique GUID's.

I think you'll find that most articles (especially those written by people
with training in Computer Science or Software Engineering) will skirt the
issue because I don't think there's an algorithm that can formally guarantee
universal unqiueness. (If there is someone *please* correct me: I'd love to
know what it is!)

But... keep in mind that a GUID is 128 bits. If you assume that 64 bits
will be used as a system identifier (like a MAC address), you would still
need more than a quadrillion GUID's before you started approaching the realm
of likely duplication. For some really crazy numbers: assume 1,000,000
computers generating a 1,000,000 GUID's a day. In a thousand years, you
would have used up around 2% of the "number space" in 64 bits. (Of course,
this is a specious example since we conveniently ignored the algorithmic
difficulty of "divying up" the range of numbers possible in 64 bits, but
it's still a cool number :)

That's why GUID's really shine in distributed environments: any computer can
generate as many unique identifiers as required. We use them for a system
we have where a client must create an "entity" that when mapped to our
relational schema could be hundreds of rows across multiple tables. And for
reasons I won't go into, the client must be able to reliably create the
entire entity before ever connecting to a server. Without GUID's (or
something similar) we'd need to something much more painful which would
probably end emulating the MS GUID algorithm anyway.

The point of the above? After millions of these "entities" and hundreds
(possibly thousands) of GUID's for COM components, we've never had a
collision. And that includes computers that have changed Ethernet cards 3
or 4 times, computers that were operated with no network adapter installed
for a week at a time, and computers with multiple adapters. And in our
initial testing for the system 3 or so years ago, we generated 500 million
GUIDS from a single computer and never had a collision.

The bottom line and my $0.02? If you decide to go with GUID's, of course
use constraints in the database like you would for any other column that is
supposed to be unique or a foreign key or whatever, but if an error is ever
detected, look for software bugs waayyyyyy before suspecting duplicate GUID
creation.

Craig

Thank You Craig.

Louis
Jul 20 '05 #4

P: n/a
Erland Sommarskog <es****@sommarskog.se> wrote in message news:<Xn**********************@127.0.0.1>...
Louis Frolio (fr*****@yahoo.com) writes:
Greetings All, I have read many upon many articles here regarding GUID
data types and uniqueness. There have been many opinions regarding
the effectiveness of GUID's and when they should/should not be used.
However, every article strongly implies, if it does not state it
outright, that GUID's are always unique. My question is this, what
happens if you have a database that uses GUID's and the NIC is changed
out on the box? From what I understand the MAC address of the NIC is
used as part of the algorithm to generate a GUID. If you change out
the NIC after generating 1 billion GUID's do you run the chance of
generating a duplicate GUID?


The MAC address thing only concerns NT4. On Win2000 and later it is
completely random.

And 1 billion is a whole lot. Even if you would happen to mean 1
milliard it is a whole lot. Even if you get 100000 orders a day, it
takes 27 years before you have a milliard of them. For a billion
orders that's 27000 years...

Thank You Erland.

Louis
Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.