Repository navigation
improvement(search): index permission-import identities by subject - #10199
Merged
waleedlatif1 merged 2 commits intoNov 19, 2026
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
[Medium impact] The PR appears safe to merge; no new actionable issues were found. SummaryThis PR speeds up permission-aware search by putting
No new actionable issues found. Reviews (2) · Last reviewed commit: "improvement(search): format migration sn..." · Reviewed by Greptile |
Contributor
There was a problem hiding this comment.
No issues found across 4 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
This PR changes a database schema or migrates data. Ultrareviews find 2.4x more serious bugs than standard reviews. Comment @cubic-dev-ai ultrareview to run one.
Turn on auto-fix | Re-trigger cubic
waleedlatif1
deleted the
fix/validate-permission-import-subject-index
branch
November 19, 2026 03:07
Collaborator
Author
This branch was previously deployed
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.
Summary
subject_tokenalone (activeConnectorPermissionGrants(), used byloadConnectorPermissionGroupTokensand the connector grant checks). The import branch's only index on that column,kcpii_subject_idx, was keyed(import_id, subject_token), so the lookup had to visit every active import (or scan the whole index) instead of jumping to the reader's identities.kcpii_subject_import_idx (subject_token, import_id). Same column set, so uniqueness is unchanged: the identity insert's untargetedON CONFLICT DO NOTHINGand the per-import conflict check (import_id+user_idORsubject_token) behave as before, and the table keeps one secondary index rather than two.kcpig_subject_idx (import_id, user_id, group_key)on the grant table already matches the follow-on join (import_id+user_id,group_key IS NOT NULL), so it is unchanged.COMMIT,CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTSfirst, thenDROP INDEX CONCURRENTLY IF EXISTSon the old one, so uniqueness never lapses. No code reads the index by name, and both index shapes serve the deployed app's queries, so it is backward-compatible with the running version.check:migrationspasses with no annotation.Plain EXPLAIN (ANALYZE) on a throwaway local database with 20k connectors (40k imports, 400k identities, 1.2M import grants), same query shape as the search path:
(import_id, subject_token)(subject_token, import_id)Release notes
Knowledge search