Skip to content

perf: eliminate N+1 queries across list views and add covering indexes#88

Merged
eclectic-coding merged 2 commits into
mainfrom
feat/query-optimisation
May 27, 2026
Merged

perf: eliminate N+1 queries across list views and add covering indexes#88
eclectic-coding merged 2 commits into
mainfrom
feat/query-optimisation

Conversation

@eclectic-coding
Copy link
Copy Markdown
Owner

@eclectic-coding eclectic-coding commented May 27, 2026

Closes #47

Summary

  • Replace per-queue COUNT loop in QueuesController#index with a single GROUP BY queue_name aggregation — was O(N) queries, now always 2
  • Combine two separate pluck calls for queue/priority filter options in JobsController#index into one query
  • Replace 5+1 separate COUNT queries in CacheSizeStats#buckets with a single SUM(CASE WHEN ...) aggregation; derive #total from the already-computed bucket counts
  • Add covering indexes to the dummy app schema: solid_queue_jobs (finished_at, created_at) for the slow-job scan; (queue_name, created_at) on solid_queue_scheduled_executions and solid_queue_blocked_executions (both previously lacked a queue-name index)
  • Move install generator docs into the Installation section of the README

Test plan

  • bundle exec rake passes (325 examples, 0 failures, no Rubocop offenses)
  • Queues index renders correctly with multiple queues and paused state
  • Jobs filter dropdowns populate queue and priority options correctly
  • Cache size distribution buckets and total count display correctly

🤖 Generated with Claude Code

eclectic-coding and others added 2 commits May 27, 2026 06:52
Replace per-queue COUNT loop in QueuesController with a single GROUP BY
aggregation; combine two separate pluck calls in JobsController into one;
replace 5+1 COUNT queries in CacheSizeStats with a single SUM(CASE WHEN)
aggregation and derive #total from bucket counts. Add covering indexes to
the dummy schema for the slow-job scan and for queue_name lookups on
scheduled and blocked execution tables.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@eclectic-coding eclectic-coding merged commit a9cd6a6 into main May 27, 2026
5 checks passed
@eclectic-coding eclectic-coding deleted the feat/query-optimisation branch May 27, 2026 10:56
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.

[v0.9.0] DX: query optimisation

1 participant