Repository navigation
Conversation
Project-page listings in all-pipelines mode filtered by ref type (e.g. "Pull Requests only") timed out on large projects. With the ref types bound as `= ANY($n)`, Postgres walked the project's history newest first and filtered row by row, reading thousands of rows when the type was rare and the whole history when it had none. Compare a single ref type as a scalar. For several types, query each one separately with its own order, keyset cursor and page limit inside a subquery, then merge them. Postgres does not push an outer ORDER BY or LIMIT into UNION ALL branches that have WHERE clauses, and with a project/ref-type index a generic plan for `= ANY($n)` fetches and sorts every matching row. Each branch now reads at most one page.
Add a (project_id, git_ref_type, inserted_at DESC, id DESC) partial index on initial pipeline requests, built concurrently. Ref-type filtered listings read it in order and stop at the page limit instead of walking the project's history. Ship together with the per-type keyset queries: the previous `= ANY($n)` query picks a bitmap scan and sort over every matching row once this index exists.
adbatista
force-pushed
the
adb/plumber-keyset-ref-type-index
branch
from
October 29, 2026 17:58
212f56d to
6e9103b
Compare
adbatista
marked this pull request as ready for review
October 29, 2026 17:59
adbatista
requested review from
DamjanBecirovic,
dexyk,
loadez and
skipi
as code owners
October 29, 2026 17:59
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6e9103b4a0
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A repeated value in git_ref_types (e.g. ["branch", "branch"]) built identical UNION ALL branches, so every matching workflow came back once per repeat and took extra slots on the page. The previous IN filter treated the values as a set; do the same before splitting per type. [api] Deduplicate git_ref_types before building per-type keyset queries [test] Cover duplicate ref types in the SQL shape and in returned pages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Description
Project-page listings in all-pipelines mode filtered by a single ref type (e.g. "Pull Requests only") timed out on large projects. With the ref type bound as
= ANY($n)under a generic plan, Postgres walked pipeline_requests_project_id_inserted_at_id and filtered row by row until it found a page, scanning the whole project history when matches were rare, and hit the 15s pool timeout.Add a (project_id, git_ref_type, inserted_at DESC, id DESC) partial index and compare a single ref type as a scalar, so the index returns rows already ordered and the scan stops at the page limit. Multiple ref types keep using ANY.
✅ Checklist