Skip to content

Partial covering index on versions for latest dependent_packages join#1657

Open
andrew wants to merge 1 commit into
mainfrom
versions-latest-covering-index
Open

Partial covering index on versions for latest dependent_packages join#1657
andrew wants to merge 1 commit into
mainfrom
versions-latest-covering-index

Conversation

@andrew
Copy link
Copy Markdown
Member

@andrew andrew commented May 27, 2026

Adds index_versions_on_id_where_latest_covering on versions (id) INCLUDE (package_id) WHERE latest = true, built concurrently with statement_timeout cleared.

The latest_dependent_packages / latest_dependent_package_kinds queries currently nested-loop probe versions_pkey and heap-fetch each row to read package_id and filter latest. With ~14M latest versions out of 163M total this index lets that probe become an index-only scan against a ~500MB partial index, and rows surviving into the HashAggregate/Sort drop from one-per-dependency-row to one-per-dependent-package.

Follows on from the API default flips so the default dependent_packages and dependent_package_kinds paths hit the latest = true branch and can use this.

Doesn't help the ?latest=false opt-out, update_dependent_packages_count, or the dependencies-side scan for npm-scale targets.

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