[CSHARP-700] Confirm intended behavior of CombGuidGenerator Created: 11/Mar/13  Updated: 20/Mar/14  Resolved: 04/Apr/13

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 1.8
Fix Version/s: 1.8.1

Type: Task Priority: Major - P3
Reporter: Robert Stam Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to CSHARP-714 New AscendingGuidGenerator Closed

 Description   

The intended behavior of CombGuidGenerator is to provide a sequence of GUID values that are in ascending order. The original article regarding CombGuids is:

http://www.informit.com/articles/article.aspx?p=25862&seqNum=7

But it is not clear that the same generation algorithm that works for SQL Server works for MongoDB. For MongoDB the sort order of GUIDs might depend on:

1. Which representation is being used for GUIDs (Standard, CSharpLegacy, etc...)
2. How the server compares two BinData values

The task for this JIRA ticket is to investigate all the factors related to CombGuidGenerator and to make any changes as might be necessary (and to document the purpose and use of CombGuids).



 Comments   
Comment by auto [ 04/Apr/13 ]

Author:

{u'date': u'2013-04-04T14:35:07Z', u'name': u'rstam', u'email': u'robert@10gen.com'}

Message: CSHARP-700: Improvements to CombGuidGenerator and its unit tests.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/05b35a03454e873f87bece6a7ce5c0aa6e199b7e

Comment by Robert Stam [ 27/Mar/13 ]

See CSHARP-714 for the new AscendingGuidGenerator that will usually be more useful with MongoDB than CombGuidGenerator.

Comment by Robert Stam [ 27/Mar/13 ]

One subtlety about why the CombGuid generator algorithm generates GUIDs that are good for SQL Server clustered indexes has to do with the very odd way SQL Server compares GUIDs. See:

http://msdn.microsoft.com/en-us/library/ms254976.aspx

That explains why CombGuid makes the last 6 bytes of the GUID ascending, and doesn't care that the high order bytes of the GUIDs it generates are random.

However, this means that the CombGuid generator algorithm is only useful when generating GUIDs for SQL Server, and therefore has limited usefulness when generating _id values for MongoDB.

We won't deprecate the CombGuidGenerator because there is one plausible use case: you are generating GUIDs for documents that will eventually be copied to SQL Server and you therefore want to use the CombGuid generator.

We will add new Guid generators for MongoDB that generate GUIDs that the MongoDB server will consider ascending.

Comment by Robert Stam [ 11/Mar/13 ]

If we end up providing a different algorithm for generating GUIDs than CombGuidGenerator I think we should also use a new name (something like AscendingGuidGenerator or SequentialGuidGenerator).

We can keep the existing CombGuidGenerator which might have some usefulness in situations where data might eventually be exported to SQL Server (or if for no other reason than backward compatibility).

Generated at Wed Feb 07 21:37:35 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.