Skip to content

Conversation

@Naragod
Copy link
Contributor

@Naragod Naragod commented Jan 15, 2026

Proposed Changes

Multiple individuals have reported slow MarkUs load times when viewing assignments, as TAs. Our investigation has found that we are running into the common N + 1 query problem. When loading the information displayed on the status column of the assignment index page, we are performing 2 calculations per assignment, each doing a join on the membership table. There are currently more than 300K rows on the membership table. This means that every assignment scans through 300K membership records.

If there are 10 assignments assigned to a particular TA, this means that there will be approximately 20 queries each scanning ~300K membership rows (we lack indexes as well) -> ~6 million row scans per page load.

To resolve this issue, we can preload all of the TA statistics and then return this information as a hash, where each key is associated to an assignment id and each value, to the status of that assignment, num_marked or num_assigned. This means we are doing a single expensive query and then presenting this data almost immediately when subsequently asked for it.

Screenshots of your changes (if applicable)
Associated documentation repository pull request (if applicable)

Type of Change

(Write an X or a brief description next to the type or types that best describe your changes.)

Type Applies?
🚨 Breaking change (fix or feature that would cause existing functionality to change)
New feature (non-breaking change that adds functionality)
🐛 Bug fix (non-breaking change that fixes an issue) X
🎨 User interface change (change to user interface; provide screenshots)
♻️ Refactoring (internal change to codebase, without changing functionality)
🚦 Test update (change that only adds or modifies tests)
📦 Dependency update (change that updates a dependency)
🔧 Internal (change that only affects developers or continuous integration)

Checklist

(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the [ ] into a [x] in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)

Before opening your pull request:

  • I have performed a self-review of my changes.
    • Check that all changed files included in this pull request are intentional changes.
    • Check that all changes are relevant to the purpose of this pull request, as described above.
  • I have added tests for my changes, if applicable.
    • This is required for all bug fixes and new features.
  • I have updated the project documentation, if applicable.
    • This is required for new features.
  • If this is my first contribution, I have added myself to the list of contributors.

After opening your pull request:

  • I have updated the project Changelog (this is required for all changes).
  • I have verified that the pre-commit.ci checks have passed.
  • I have verified that the CI tests have passed.
  • I have reviewed the test coverage changes reported by Coveralls.
  • I have requested a review from a project maintainer.

Questions and Comments

(Include any questions or comments you have regarding your changes.)

@Naragod Naragod added this to the v2.9.1 milestone Jan 15, 2026
@Naragod Naragod requested a review from donny-wong January 15, 2026 19:15
@coveralls
Copy link
Collaborator

coveralls commented Jan 15, 2026

Pull Request Test Coverage Report for Build 21258432992

Details

  • 69 of 69 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.01%) to 91.654%

Totals Coverage Status
Change from base Build 21224303427: 0.01%
Covered Lines: 44364
Relevant Lines: 47596

💛 - Coveralls

@Naragod Naragod force-pushed the TICKET-574_improve_ta_assignment_load_time branch from 3548e16 to 4c06222 Compare January 19, 2026 15:04
@donny-wong donny-wong removed their request for review January 21, 2026 14:34
@Naragod Naragod force-pushed the TICKET-574_improve_ta_assignment_load_time branch from 4c06222 to 1bb1da9 Compare January 22, 2026 17:34
@Naragod Naragod requested a review from david-yz-liu January 23, 2026 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants