472,327 Members | 1,252 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,327 software developers and data experts.

Is a GUID always unique?

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
4 15493
"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
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
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Joe Wong | last post by:
Hi, I need to implement a unique number generator that 1 or more processes on same or different machines will make use of it. Is there any library...
2
by: Robert Oschler | last post by:
Anybody seen a Javascript function that would generate a fairly robust equivalent to the Windows GUID (Globally Unique Identifier)? thx ...
2
by: Mullin | last post by:
I need to generate a unique no. in the format like yyyymmddxxxxxx (xxxxxx 6-digitl running number) I think of create a table with two columns ...
1
by: hikums | last post by:
I am posting this here, just in case anyone may need this. Step 1: CREATE SEQUENCE ID_SEQ START WITH 1050000 INCREMENT BY 1 MAXVALUE 9999999...
3
by: Kilroy Programmer | last post by:
Is there a way to store a unique numeric identifier (say, for example, an int) into a TreeNode, so that when the TreeNode is checked (since...
4
by: Alexander Muylaert | last post by:
Hi I need a unique key for an object. This key needs to be globally unique. A GUID serves my needs, but... Is somebody aware of a guid...
2
by: Chris Dunaway | last post by:
I have a web service which is accessed by a windows forms application. When the application submits a unit of work (a "job"), I want to return a...
15
by: Ashish Khandelwal | last post by:
As MSDN is not giving us guarantee upon uniqueness of Hash Code, so could any one suggest me that how to generate a unique Hash Code for same...
2
by: Gary Hasler | last post by:
Does anyone have any suggestions on generating GUID (Globally Unique Identifier) tags with php? They would need to be in the format...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.