Skip to content

perf: index the PostgreSQL pushes hot paths and slim list projections - #1692

Open
dcoric wants to merge 3 commits into
finos:feat/postgresfrom
dcoric:feat/postgres-pushes-perf
Open

perf: index the PostgreSQL pushes hot paths and slim list projections#1692
dcoric wants to merge 3 commits into
finos:feat/postgresfrom
dcoric:feat/postgres-pushes-perf

Conversation

@dcoric

@dcoric dcoric commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Indexes the PostgreSQL pushes hot paths and aligns list projections with the mongo backend. Extension of #1532 and #1581, stacked on the schema migrations branch; prompted by the review remark on #1532 that the pushes table is the scale concern.

Push rows carry the full diff inside steps, so any query reading the data JSONB detoasts very large rows. This PR:

  • adds schema migration v6 pushes_hot_path_indexes: a covering expression index that turns the repo activity rollup into an index-only scan (it previously detoasted every push row on every repos page), a partial index matching the default pending-review dashboard query, and expression indexes for the user profile predicates
  • changes list queries (getPushes, getPushesForUserProfile) to select data - 'steps', matching the mongo backend's list projection, which also excludes steps; the push detail view (getPush) still returns the full document
  • reserves migration versions 4 and 5 for the repo_users normalisation branch (feat: normalise PostgreSQL repo permissions into a repo_users join table #1590), documented in the registry; the runner applies by version order so the gap is harmless

The wider question of shrinking the stored push document itself (the diff is currently stored twice per push, in steps[].logs and steps[].content, across all backends) is deliberately out of scope here and tracked in #1691.

Like the other stacked PRs, the diff shown includes the parent branches until they merge into feat/postgres; this PR's own change is the last commit.

Resolves #1690

Push rows carry the full diff inside steps, so queries that read the
data JSONB detoast very large rows. Three hot paths paid for that:

- the repo activity rollup scanned and detoasted every push row on
  every repos page; a covering expression index makes it an index-only
  scan that never touches the heap
- the default dashboard query gets a matching partial index, and the
  user profile predicates get expression indexes
- list queries now select data minus the steps key, matching the mongo
  backend's list projection, which also excludes steps; the push detail
  view still returns the full document

Indexes ship as schema migration v6. Versions 4 and 5 are reserved by
the repo_users normalisation branch, and the runner applies in version
order, so the gap is harmless.
@dcoric
dcoric marked this pull request as ready for review August 24, 2026 10:21
@dcoric
dcoric requested a review from a team as a code owner August 24, 2026 10:21
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.

1 participant