Skip to content

Compute lead status statistics from one grouped database query - #2

Merged
bconnell merged 8 commits into
mainfrom
perf/single-query-lead-stats-20261017
Oct 18, 2026
Merged

bconnell merged 8 commits into
mainfrom
perf/single-query-lead-stats-20261017

Conversation

@bconnell

@bconnell bconnell commented Oct 18, 2026 •

Copy link
Copy Markdown
Owner

Problem

The lead statistics endpoint performed six separate count queries, allowing inconsistent results if commits occurred between them and adding unnecessary database work.

Changes

  • Use one JPQL grouped database query with a typed LeadStatusCount result.
  • Sum returned groups for total, and return zeros for absent statuses without loading lead entities.
  • Preserve the HTTP response shape, status names, and existing behavior.
  • Test grouped results, missing statuses, empty datasets, and single repository invocation across unit, H2 HTTP, and PostgreSQL HTTP coverage.
  • Document query structure and evidence without claiming a measured speedup.

Verification

  • Final head: 6384abe9d1eada1f4f0344358880eb851187dd4f.
  • Final GitHub Actions CI run 39083417179: completed successfully.
  • Maven clean verify: 41 application tests and 5 PostgreSQL Testcontainers integration tests. No failures, errors, or skips.
  • Spring Boot packaging, PostgreSQL Compose health/readiness and cleanup all succeeded.
  • No Flyway migrations, HTTP contract changes, or new dependencies.
  • Change confined to the statistics repository/service, their regression tests, and documentation.

Limit

A reduction from six count statements to one is verified by implementation and tests. No workload benchmark or measured latency improvement is claimed.

@bconnell
bconnell marked this pull request as ready for review October 18, 2026 00:38
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T00:39:31.332742Z 6384abe Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@bconnell
bconnell merged commit e7c1f6b into main Oct 18, 2026
1 check passed
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.

1 participant