Add the missing indexes to the CockroachDB schema - #5361
Merged
Conversation
adutra
approved these changes
Aug 24, 2026
Contributor
Author
|
@adutra could you re-run the failed job? |
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.
cockroachdb/schema-v6.sqldeclares 7 indexes wherepostgres/schema-v6.sqldeclares 10, though its own header says it matches PostgreSQL schema v6. #3939 added the three to Postgres and H2, fixing #3685; #3352 had branched the CockroachDB script from Postgres v4 a week earlier.idx_grants_realm_granteeis the one that changes a plan. Thegrant_recordsprimary key continues with the securable columns afterrealm_id, soloadAllGrantRecordsOnGrantee, which filtersrealm_id,grantee_catalog_idandgrantee_id, can use only the realm prefix.EXPLAIN ANALYZEon CockroachDB 25.3, 200k grant records in one realm: 200,000 KV rows in 61ms ongrant_records_pkey, against 200 rows in 377µs on the new index.Measured, the other two change no plan: the primary key already yields exact spans for the securable lookup and for the entities tuple-
INquery. They are declared so schema v6 means the same objects on every backend, as #5349's v3-to-v4 migration assumes; itscockroachdb/schema.sqlstill lacks all three.Only
schema-v6.sqlis touched; v4 and v5 have shipped. Existing deployments need the one-time DDL in the CHANGELOG upgrade notes. The Cockroach bootstrap, purge and IT suites run this script against a real container in CI.Checklist
create_namespaceLatency (>30s) - Schema & Query Optimization Required #3685CHANGELOG.md(if needed)site/content/in-dev/unreleased(if needed)