.net - UUID collision risk using different algorithms -


I have a database where 2 (or maybe 3 or 4) are entering different application information. There are GUID / UUID ID types, but using different algorithms to generate each ADS ID. For example, someone using NHibernate's "guid.comb", is using another SQLServer's NEWID (), others may want to use the .Net Guid.NewGuid () implementation.

Is there a general risk above ID collision or duplicate?

Thank you!

The risk of collisions has increased, but still small, consider it small:

  • Both comb and NEWID / NEWSEQUENTIALID contains a timestamp with some MS with precise below . Thus, as long as you are not generating a large number of IDs from these different sources at exact same time period , then it is really impossible colliding for the ID.

  • The part of the GUID that is not based on the timestamp can be considered randomly; The most GUID algorithm, based on one PRGG, is based on these points. Thus, the possibility of confrontation between these other 10 bytes is in this order as if you use two different random number generators and look for a collision.

    Think for a moment about this - PRNG and repetitive numbers, so the probability of collision between two of them is not much higher than the collision using only one of them, even if They use a slightly different algorithm It's like playing the same lottery number every week. Taking the random set every week - Obstacles to victory are exactly the same.

Now, keep in mind that when you use algorithms like guides.com, you have only 10 bits unique, which is equal to 1024 different values . So if you are creating the same large number of GUIDs in milliseconds, then you will get conflicts but if you generate a GUID at a much lower frequency, then it is actually a It does not matter how many different algorithms you use at the same time, the possibility of confrontation is still practically none.

The best way for you is to definitely run a test; All 2 or 3 (or the more you use), at the same time, generate a GUID at regular intervals, and write them in a log file, and see if you are confronted (and if so, how many) . It should give you a good idea how safe it is in practice.

P.S. If you are using NHibernate's comb generator to generate GUID for a clustering primary key, then using NEWID () instead of NEWSEQUENTIALID () Consider page segmentation, and you are not complete that if you have other processes using non-sequential algorithms. You must change any code by using the Guid.NewGuid to use the same blanket generator - the real-cut algorithm used in NHibernate is easy to duplicate in your domain argument.

† Note that there is some controversy about NEWID , and whether it involves a timestamp or not. In any case, because it is based on MAC address, the range of possible values ​​is much lower than the V4 GUID or the Combine to advise the paste of the junk GUID out of the database and inside the NEWSEQUENTIALID database


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -