Add database indexes for user-scoped queries
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 10
- Forks
- 0
- Avg merge
- 2h 52m
- Merged PRs (30d)
- 20
Description
Tier 2 — scale
Problem
Every query in the app filters by UserId, and there is no index on UserId for LearningResources, ContentIdeas or SharedResourceGroups. The only indexes configured are the unique ones on ShareToken and invitation Token. Every page load is a table scan — and because thumbnails live on the same row (see #45), each scan drags the blobs with it.
Evidence
LearnStack.Core/Data/ApplicationDbContext.cs—OnModelCreatingdefines indexes only onSharedResourceGroup.ShareToken,FriendInvitation.Tokenand the friendship pair
Proposed fix
Add in a migration:
LearningResources (UserId, IsArchived, Status)LearningResources (UserId, IsPublic)filtered onIsPublic = 1ContentIdeas (UserId, Status)SharedResourceGroups (UserId)
Then confirm with actual execution plans on a seeded dataset.
Acceptance criteria
- No table scans on the resource list, Pulse or content-ideas pages
- Index usage verified against a dataset of ~10k resources
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in LearnStack.Core/Data/ApplicationDbContext.cs by reviewing OnModelCreating and then inspect the existing migration setup. Apply the proposed indexes, seed roughly 10k resources, and compare execution plans for the resource list, Pulse, and content-ideas queries. Done means those queries show index usage with no table scans.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, sql
- Domain
- backend, databases, performance
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100