Skip to content

[PERFORMANCE] [MER-5838] Scope Insights page attempts to delivery - #6770

Merged
nicocirio merged 3 commits into
masterfrom
MER-5838-slow-insights-page-detail-loading
Aug 18, 2026
Merged

[PERFORMANCE] [MER-5838] Scope Insights page attempts to delivery#6770
nicocirio merged 3 commits into
masterfrom
MER-5838-slow-insights-page-detail-loading

Conversation

@nicocirio

@nicocirio nicocirio commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Jira

Summary

Scopes Oli.Publishing.DeliveryResolver.students_with_attempts_for_page/3 to the
delivery project (project_id = -1).

Previously, the query included resource_summary rows from unrelated authoring
projects that happened to reference the same resource. That could include students
without delivery attempts for the selected page and caused the page-detail query to
scan a large portion of resource_summary.

The new scope returns only delivery analytics data and lets PostgreSQL use the
existing resource_summary_scopes index.

Performance Impact

Validation used a dedicated local database with 10,000,351 resource_summary
rows: 500 enrolled students, 350 delivery attempts on the selected scored page,
and 10,000 unrelated project scopes per student across scored and practice pages.
Both query versions ran against this exact same dataset.

Each query was measured five times with EXPLAIN ANALYZE; the values below are
median execution times.

Query Original With this change Improvement
Oli.Publishing.DeliveryResolver.students_with_attempts_for_page/3 3,797.59 ms 1.04 ms 3,796.55 ms (99.97%, ~3,651x)

The original plan used a parallel sequential scan over approximately 5 million
page-related resource_summary rows, including unrelated project scopes. The
updated plan uses an index-only scan through resource_summary_scopes and reads
only the relevant delivery scope.

The temporary seed and benchmark harness is preserved for reference in
benchmark v1.

Validation

  • Added a regression test proving that only delivery-scope attempt summaries are
    considered.
  • Ran mix test test/oli/publishing/delivery_resolver_students_with_attempts_test.exs.
  • Manually navigated to the selected scored-page detail view and applied its
    filters with the same seeded database: approximately five seconds on master,
    effectively instantaneous on this branch.

Video Evidence

Before (master)

before.mov

After (this branch)

after.mov

@gitguardian

gitguardian Bot commented Aug 12, 2026

Copy link
Copy Markdown

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
36041959 Triggered Company Email Password 950700a priv/scenarios/insights_page_detail_perf.scenario.yaml View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@github-actions

Copy link
Copy Markdown
Contributor

Risk score: 4 → risk/medium

Generated by 🚫 dangerJS against 9d428ba

@github-actions

Copy link
Copy Markdown
Contributor

AI Review — performance

No issues found

@github-actions

Copy link
Copy Markdown
Contributor

AI Review — security

No issues found

@github-actions

Copy link
Copy Markdown
Contributor

AI Review — elixir

No issues found

@nicocirio
nicocirio marked this pull request as ready for review August 18, 2026 11:20
@nicocirio
nicocirio merged commit 1d04142 into master Aug 18, 2026
23 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants