[BEEEP][SM-1061] Add missing vault table indexes to EF config#63
Open
lizard-boy wants to merge 2 commits into
Open
[BEEEP][SM-1061] Add missing vault table indexes to EF config#63lizard-boy wants to merge 2 commits into
lizard-boy wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
12 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile
Comment on lines
+15
to
+29
| 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.
logic: NpgsqlIndexBuilderExtensions is used, which may not be compatible with other database providers
Comment on lines
+15
to
+19
| NpgsqlIndexBuilderExtensions.IncludeProperties( | ||
| builder.HasIndex(f => f.UserId) | ||
| .IsClustered(false), | ||
| f => | ||
| new { f.Name, f.CreationDate, f.RevisionDate }); |
There was a problem hiding this comment.
logic: NpgsqlIndexBuilderExtensions is specific to PostgreSQL. This may cause issues with other database providers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
IEntityTypeConfigurationand configuration folder approach.src/Infrastructure.EntityFramework/Vault/Configurations/CipherEntityTypeConfiguration.cs:
src/Infrastructure.EntityFramework/Vault/Configurations/FolderEntityTypeConfiguration.cs:
Extracted into the
IEntityTypeConfigurationand 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.
CipherEntityTypeConfigurationandFolderEntityTypeConfigurationclasses to configure entity-specific indexesUserIdandOrganizationIdforCiphertable with included propertiesOrganizationId,DeletedDate, andUserIdforCiphertableUserIdforFoldertable with included properties