Fix relational JDBC location-overlap index to match the optimized sibling-check query - #5301
Merged
adutra merged 3 commits intoAug 24, 2026
Merged
Conversation
iprithv
force-pushed
the
fix/jdbc-location-overlap-index-catalog-id
branch
from
August 16, 2026 18:12
ee5fa47 to
135ed26
Compare
adutra
reviewed
Aug 18, 2026
…ling-check query The optimized sibling check reads location_without_scheme via QueryGenerator.generateOverlapQuery, which filters `realm_id` and `catalog_id`. On Postgres and CockroachDB the idx_locations index led with `parent_id` instead of `catalog_id`, so the predicate could only probe the realm_id prefix and every CREATE TABLE / CREATE NAMESPACE with OPTIMIZED_SIBLING_CHECK enabled fell back to a scan instead of the intended indexed lookup. H2 already used the correct columns. Schema v5 has already shipped in 1.7.0, so rather than editing a released script this adds schema v6 for all backends with the corrected index and bumps the latest schema version. Fresh installs bootstrap at v6 and get the right index automatically. Existing deployments need a one-time manual index recreation, documented in the changelog upgrade notes, because Polaris has no automated schema migrations.
iprithv
force-pushed
the
fix/jdbc-location-overlap-index-catalog-id
branch
from
August 18, 2026 19:19
135ed26 to
3a082e4
Compare
|
I would like to work on this issue. |
Contributor
Thanks @zhang-arvin - This is already being handled here. Please close #5331 so we keep the discussion in one place. |
adutra
previously approved these changes
Aug 19, 2026
| -- | ||
|
|
||
| -- Changes from v5: | ||
| -- * Schema version bumped to keep H2 in lockstep with Postgres/CockroachDB v6, which correct the |
Contributor
There was a problem hiding this comment.
That's an interesting issue. I'm not sure we need to keep the scripts in lockstep.
Contributor
There was a problem hiding this comment.
Let's actually keep them in sync. This will make the migration to single DDL scripts easier imho. See #5349.
Contributor
|
@iprithv could you please fix the merge conflicts? 🙏 |
Contributor
Author
|
@adutra sure, done. thanks! |
adutra
approved these changes
Aug 24, 2026
adutra
enabled auto-merge (squash)
August 24, 2026 10:00
6 tasks
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.
The optimized sibling check
(OPTIMIZED_SIBLING_CHECK)reads location_without_scheme through QueryGenerator.generateOverlapQuery, whose predicate isWHERErealm_id = ?AND catalog_id = ? AND (...).On Postgres and
CockroachDB, idx_locations currently leads with parent_id instead of catalog_id:-- before (
postgres/cockroachdb)ON entities USING btree (
realm_id, parent_id, location_without_scheme)Because of that, the query can only use the
realm_idprefix and ends up doing a realm/catalog-wide scan instead of the intended indexed lookup. H2 already uses (realm_id, catalog_id, location_without_scheme), which is why the default H2-based test matrix didn't catch this.This changes the latest (v5) Postgres and CockroachDB scripts to use (
realm_id, catalog_id, location_without_scheme) and adds SchemaLocationIndexParityTest to make sure the idx_locations column list stays consistent across backends.Older scripts (v2-v4) are intentionally left unchanged. Fresh installs always start at the latest schema version, so those scripts are frozen. Existing realms on older versions are covered by the manual DDL in CHANGELOG.md.
The optimized sibling check is meant to replace an O(siblings) listing with an indexed lookup. With the current index on Postgres and CockroachDB, table/namespace creation can instead scale with the total catalog size.
Polaris doesn't have automated schema migrations, so existing Postgres/CockroachDB deployments will need to recreate the index manually:
H2 is unaffected.