Add database indexes for perf improvements#1318
Merged
Merged
Conversation
morganbr
requested changes
May 19, 2026
| protected override void OnModelCreating(ModelBuilder modelBuilder) | ||
| { | ||
| modelBuilder.Entity<ContentFile>().HasIndex(contentFile => new { contentFile.EventID, contentFile.ShortName }).IsUnique(); | ||
| modelBuilder.Entity<ContentFile>().HasIndex(contentFile => new { contentFile.EventID, contentFile.FileType}).IncludeProperties(contentFile => new { contentFile.ShortName, contentFile.UrlString, contentFile.PuzzleID}).IsUnique(); |
Contributor
There was a problem hiding this comment.
This should be non-unique since we can have multiple puzzles/solutions in an event
Contributor
There was a problem hiding this comment.
I'd be lying if I said I truly knew how to read this line of code, but short names and URL strings are unique per event, correct?
|
|
||
| b.HasIndex("PuzzleID"); | ||
|
|
||
| b.HasIndex("EventID", "FileType") |
Contributor
There was a problem hiding this comment.
You'll need to regenerate the 3 migration files after your fixes to the model
| modelBuilder.Entity<Room>().HasIndex(room => new { room.EventID, room.Building, room.Number }).IsUnique(); | ||
| modelBuilder.Entity<PlayerInEvent>().HasIndex(pie => new { pie.PlayerId, pie.EventId}); | ||
| modelBuilder.Entity<PuzzleUser>().HasIndex(pu => new { pu.IdentityUserId}); | ||
| modelBuilder.Entity<TeamMembers>().HasIndex(tm => new { tm.ID }); //EF can't parse this for nested types, so this is a placeholder to manually edit the generated model to INDEX Team.ID, User.ID, INCLUDE Class.ID, ID, TemporaryClassID |
Contributor
There was a problem hiding this comment.
It looks like the existing clustered index should be on this column. Does this have an effect?
morganbr
approved these changes
May 21, 2026
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.
No description provided.