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

Dynamic UUID/GUIDs for better performance #15518

Open
yuriy-yarosh opened this issue Jan 26, 2023 · 5 comments
Open

Dynamic UUID/GUIDs for better performance #15518

yuriy-yarosh opened this issue Jan 26, 2023 · 5 comments
Labels

Comments

@yuriy-yarosh
Copy link

Description

GUID Generation Documentation clearly says that:

GUIDs are impossible to guess, so they can be more secure compared to auto-increment Id values in some cases.

There's nothing wrong with the GUID's themselves it's just they're causing RDBMS Index Bloat and inherent perf degration during index traversal. Is it possible to implement a custom GUID mapping, on top of EF Core, for Dynamic GUID Sizing ?

People do often consider ULIDs to be a better replacement, and most of the existing benchmarks show that this actually can be a perf limitation fairly often, alongside with the entropy pool leaks.

Analysis

I do like the way instagram handles their complex PKey / uuid situation with constrained 64bit keys, and I find it the most performant and flexible approach.

From DBA side of things there are really clever ways to handle such cases, even if it means extending the database engine directly. At the framework side, such issues perceived as non-critical, even if it literally means speeding up inserts about 10x times and reducing the indices about 3x times.

@maliming
Copy link
Member

hi

You can replace the IGuidGenerator with yours. : )

@maliming maliming removed the problem label Jan 27, 2023
@yuriy-yarosh
Copy link
Author

yuriy-yarosh commented Jan 29, 2023

@maliming I'm talking about replacing GUID's enterily, with any variable-coding capable ID format.
It's simpler, for me, to drop ABP entirely, and use something more mature from the DBA perspective.

@stale
Copy link

stale bot commented Apr 2, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the inactive label Apr 2, 2023
@dinhduongha
Copy link

@yuriy-yarosh You can create Store Procedure name next_uuid as I do. This code work as ULID with data type is uuid.
Set default Id in code:
`

modelBuilder.Entity<ResCompany>(entity =>
{
entity.Property(e => e.Id)
.HasDefaultValueSql("next_uuid()")
.HasColumnName("id");
}
`

Or you replace default IGuidGenerator with your own:
`

public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure(options =>
{
options.DefaultSequentialGuidType = SequentialGuidType.SequentialAsString;
});
context.Services.Replace(ServiceDescriptor.Transient<IGuidGenerator, MySequentialGuidGenerator>());
}
`

I used in my project BambooERP

@stale stale bot removed the inactive label May 4, 2023
@stale
Copy link

stale bot commented Aug 10, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the inactive label Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants