kasuken / kasuken/LearnStack

Add database indexes for user-scoped queries

Open
#46 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
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.csOnModelCreating defines indexes only on SharedResourceGroup.ShareToken, FriendInvitation.Token and the friendship pair
Proposed fix

Add in a migration:

  • LearningResources (UserId, IsArchived, Status)
  • LearningResources (UserId, IsPublic) filtered on IsPublic = 1
  • ContentIdeas (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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.