Skip to content

SequentialGuid

sdrapkin edited this page Mar 26, 2017 · 10 revisions

SequentialGuid.CreateSequentialGuid() located in TinyORM.Helpers creates a System.Guid that is greater than any GUID previously generated by this function on a current WindowsOS since that WindowsOS was started. After restarting WindowsOS, the GUIDs can start again from a lower range, but they will still be globally unique.

TinyORM's sequential .NET GUIDs have the following advantages over other COMBined GUID approaches:

  • As effective as TSQL-based NEWSEQUENTIALID in avoiding GUID-based index fragmentation and page cache pressure.
  • Extremely fast. CreateSequentialGuid() runtime cost is similar to calling Guid.NewGuid() twice.
  • Provides 64 bits of cryptographically-strong entropy/randomness.
    • Google required 2+ years and 2^63 computations to find a SHA1 collision.
  • Captures creation DateTime with ~7min accuracy.
    • Creation DateTime can be extracted with SequentialGuid.ExtractDateTimeUtc(guid).
  • Works perfectly across multiple Threads, AppDomains, and Processes.
    • No synchronization costs are incurred, since all synchronization happens at the WindowsOS level.
Clone this wiki locally