Skip to content

perf: eliminate N+1 SQL queries in _compute_summaries#244

Open
ankitwasankar wants to merge 1 commit intotirth8205:mainfrom
ankitwasankar:main
Open

perf: eliminate N+1 SQL queries in _compute_summaries#244
ankitwasankar wants to merge 1 commit intotirth8205:mainfrom
ankitwasankar:main

Conversation

@ankitwasankar
Copy link
Copy Markdown

Issue fix: #243

Replace per-community and per-node query loops with precomputed aggregate queries + executemany batch inserts.

community_summaries: 2 queries per community -> 3 total

  • single GROUP BY query for top symbols across all communities
  • single flat SELECT for all file paths across all communities
  • executemany batch insert replaces per-community INSERT

risk_index: 3 queries per node -> 3 total

  • single GROUP BY query for all caller counts
  • single SELECT for all tested qualified names
  • executemany batch insert replaces per-node INSERT

On a repo with ~17k nodes and ~500 communities this reduces ~54,000 SQL round-trips to ~6, eliminating the build hang.

Replace per-community and per-node query loops with precomputed
aggregate queries + executemany batch inserts.

community_summaries: 2 queries per community -> 3 total
- single GROUP BY query for top symbols across all communities
- single flat SELECT for all file paths across all communities
- executemany batch insert replaces per-community INSERT

risk_index: 3 queries per node -> 3 total
- single GROUP BY query for all caller counts
- single SELECT for all tested qualified names
- executemany batch insert replaces per-node INSERT

On a repo with ~17k nodes and ~500 communities this reduces
~54,000 SQL round-trips to ~6, eliminating the build hang.
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