Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs related to version 7 GUID generation #349

Merged
merged 1 commit into from
Sep 1, 2024
Merged

Docs related to version 7 GUID generation #349

merged 1 commit into from
Sep 1, 2024

Conversation

roji
Copy link
Member

@roji roji commented Sep 1, 2024

See npgsql/efcore.pg#3249

/cc @ChrisJollyAU @Timovzl, here are some docs on the UUIDv7 change - let me know if you have any feedback!

@roji roji merged commit 2322a1a into npgsql:main Sep 1, 2024
1 check passed
@roji roji deleted the Guidv7 branch September 1, 2024 16:59
github-actions bot pushed a commit that referenced this pull request Sep 1, 2024
@@ -92,17 +92,17 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)

## GUID/UUID Generation

By default, for GUID key properties, a random GUID is generated client-side by the EF provider and sent to the database.
By default, for GUID key properties, a GUID is generated client-side by the EF provider and sent to the database. From version 9.0 and onwards, these GUIDs are sequential (version 7), which are more optimized for database indexes (before version 9.0, these GUIDs were random).
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Consider emphasis on the word key.

I personally read over this without much realization, until I read the next paragraph.


When your entity types have a `Guid` key, EF Core by default generates key values for new entities client-side - in .NET - before inserting those entity types to the database; this can be better for performance in some situations. Before version 9.0, the provider generated random GUIDs (version 4) by calling the .NET [`Guid.NewGuid()`](https://learn.microsoft.com/en-us/dotnet/api/system.guid.newguid?view=net-8.0#system-guid-newguid) function. Unfortunately, random GUIDs aren't ideal for database indexing and can cause performance issues.

Version 9.0 of the provider now generates the recently standardized version 7 GUIDs, which is a sequential GUID type that's more appropriate for database indexes and improves their performance. This new behavior is by default and will take effect simply by upgrading the provider version.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: Was "this new behavior is by default" intended to read "this new behavior is on/enabled by default"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants