-
Notifications
You must be signed in to change notification settings - Fork 3
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
fix(db): Add missing indexes for search #2015
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThis pull request enhances database indexing and collation settings for dialog and soft deletable entities. The changes update the dialog entity configuration with new indexes and enforce case-sensitive string comparisons by setting collation "C". A new migration is added to create and drop specific indexes on the dialog table, and an index is introduced on the soft deletion field to improve query performance. Changes
Possibly related PRs
Suggested reviewers
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
9ca1ce5
to
35f4f14
Compare
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.
Actionable comments posted: 1
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
src/Digdir.Domain.Dialogporten.Infrastructure/Persistence/Migrations/20250305165700_AddMissingSearchIndexesExtStatusExtRefDeleted.Designer.cs
is excluded by!**/Migrations/**/*Designer.cs
src/Digdir.Domain.Dialogporten.Infrastructure/Persistence/Migrations/DialogDbContextModelSnapshot.cs
is excluded by!**/Migrations/DialogDbContextModelSnapshot.cs
📒 Files selected for processing (3)
src/Digdir.Domain.Dialogporten.Infrastructure/Persistence/Configurations/Dialogs/DialogEntityConfiguration.cs
(1 hunks)src/Digdir.Domain.Dialogporten.Infrastructure/Persistence/Migrations/20250305165700_AddMissingSearchIndexesExtStatusExtRefDeleted.cs
(1 hunks)src/Digdir.Library.Entity.EntityFrameworkCore/Features/SoftDeletable/SoftDeletableExtensions.cs
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Dry run deploy apps / Deploy migration job to test
- GitHub Check: build / build-and-test
🔇 Additional comments (10)
src/Digdir.Library.Entity.EntityFrameworkCore/Features/SoftDeletable/SoftDeletableExtensions.cs (1)
90-91
: Good enhancement: Adding index on Deleted field improves query performance.Adding an index on the
Deleted
property for all soft-deletable entities is a valuable improvement. This will significantly optimize query performance when filtering out soft-deleted records, which is a common operation since the query filterx => !x.Deleted
is applied to all soft-deletable entities.src/Digdir.Domain.Dialogporten.Infrastructure/Persistence/Migrations/20250305165700_AddMissingSearchIndexesExtStatusExtRefDeleted.cs (3)
7-9
: Migration class name accurately reflects its purpose.The class name
AddMissingSearchIndexesExtStatusExtRefDeleted
clearly indicates the purpose of adding indexes for ExtendedStatus, ExternalReference, and Deleted fields, which aligns with the PR objectives.
13-32
: Well-structured index creation for improved search performance.These four indexes on
Deleted
,ExtendedStatus
,ExternalReference
, andVisibleFrom
columns will improve query performance for dialog search operations. The migration correctly creates each index with appropriate naming conventions.
37-51
: Proper implementation of Down method for reversibility.The
Down
method properly drops all created indexes in the reverse order, ensuring clean migration rollback if needed.src/Digdir.Domain.Dialogporten.Infrastructure/Persistence/Configurations/Dialogs/DialogEntityConfiguration.cs (6)
14-18
: Good index addition and collation setting for ServiceResource.Adding an index on
ServiceResource
and setting case-sensitive collation with "C" will improve search performance and ensure proper string comparison behavior.
20-22
: Enhanced indexing and case-sensitive comparison for Party field.Adding an index on the
Party
field and setting case-sensitive collation will improve query performance when filtering by party.
24-30
: Well-designed indexing strategy for organizational uniqueness.Good implementation of:
- A simple index on
Org
for regular filtering- A composite unique index on
{Org, IdempotentKey}
with a null filter- Case-sensitive collation for the
Org
fieldThis approach ensures both efficient querying and proper enforcement of business constraints.
31-32
: Appropriate length constraint for IdempotentKey.Setting the maximum length of
IdempotentKey
to 36 characters is appropriate for storing UUID/GUID values.
36-37
: Temporal field indexing enhances date-based filtering.Adding indexes on both
DueAt
andVisibleFrom
will improve performance for date range queries and filtering dialog records based on temporal constraints.
39-40
: Search performance improvement for extended fields.Adding indexes on
ExtendedStatus
andExternalReference
fields will enhance search performance when filtering dialogs based on these attributes, which aligns with the PR objectives.
Description
Adding indexes for dialog
Related Issue(s)
Verification
Documentation
docs
-directory, Altinnpedia or a separate linked PR in altinn-studio-docs., if applicable)