-
Notifications
You must be signed in to change notification settings - Fork 1
[BEEEP][SM-1061] Add missing vault table indexes to EF config #63
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
12 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile
NpgsqlIndexBuilderExtensions.IncludeProperties( | ||
builder.HasIndex(c => new { c.UserId, c.OrganizationId }) | ||
.IsClustered(false), | ||
c => | ||
new | ||
{ | ||
c.Type, | ||
c.Data, | ||
c.Favorites, | ||
c.Folders, | ||
c.Attachments, | ||
c.CreationDate, | ||
c.RevisionDate, | ||
c.DeletedDate, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: NpgsqlIndexBuilderExtensions is used, which may not be compatible with other database providers
NpgsqlIndexBuilderExtensions.IncludeProperties( | ||
builder.HasIndex(f => f.UserId) | ||
.IsClustered(false), | ||
f => | ||
new { f.Name, f.CreationDate, f.RevisionDate }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: NpgsqlIndexBuilderExtensions is specific to PostgreSQL. This may cause issues with other database providers.
Type of change
Objective
The purpose of this PR is to add any missing indexes we have on Microsoft SQL Server configurations to the Entity Framework table configurations.
For this PR, I'll be excluding indexes that require custom filters because EF doesn't have a good way to handle them for multiple target database providers.
This was moved from bitwarden#2947 for just the vault tables.
Code changes
src/Infrastructure.EntityFramework/Repositories/DatabaseContext.cs:
Extracting tables that required indexes into the
IEntityTypeConfiguration
and configuration folder approach.src/Infrastructure.EntityFramework/Vault/Configurations/CipherEntityTypeConfiguration.cs:
src/Infrastructure.EntityFramework/Vault/Configurations/FolderEntityTypeConfiguration.cs:
Extracted into the
IEntityTypeConfiguration
and configuration folder approach.Adding missing indexes.
util/MySqlMigrations/Migrations/*:
MySql EF migrations
util/PostgresMigrations/Migrations/*:
Postgres EF migrations
util/SqliteMigrations/Migrations/*:
Sqlite EF migrations
Before you submit
dotnet format --verify-no-changes
) (required)Greptile Summary
This pull request adds missing indexes to Entity Framework configurations for vault tables, focusing on improving query performance for Cipher and Folder entities across multiple database providers.
CipherEntityTypeConfiguration
andFolderEntityTypeConfiguration
classes to configure entity-specific indexesUserId
andOrganizationId
forCipher
table with included propertiesOrganizationId
,DeletedDate
, andUserId
forCipher
tableUserId
forFolder
table with included properties