Data: build declared indexes CONCURRENTLY on Postgres#81
Merged
Conversation
Declaring an index on a large, live collection shouldn't block writes. On Postgres the documents expression index is now created/dropped with CREATE/DROP INDEX CONCURRENTLY; SQLite keeps plain CREATE/DROP INDEX. - Dialect gains createIndex(name, expr)/dropIndex(name) so the keyword set is per-backend. setIndexes drops its surrounding transaction (CONCURRENTLY can't run in one) and runs the declaration update + index DDL as sequential autocommit statements; the shared physical index is still dropped only once the last project undeclares it. Verification: 66/66 SQLite (the index unit tests still see the expected expression index in sqlite_master), 48/48 Postgres 16 — the declared-indexes HTTP test exercises the CONCURRENTLY path (which errors inside a txn if mis-wired). Docs + roadmap updated.
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.
What
Final operator item from the roadmap. Declaring an index on a large, live collection shouldn't block writes — so on Postgres the documents expression index is now built and dropped with
CREATE/DROP INDEX CONCURRENTLY. SQLite keeps plainCREATE/DROP INDEX(different locking model, single-VM).How
createIndex(name, expr)/dropIndex(name)so the keyword set is per-backend (CONCURRENTLYonly on Postgres).setIndexesdrops its surrounding transaction —CREATE INDEX CONCURRENTLYcan't run inside one — and instead runs the declaration update + index DDL as sequential autocommit statements (eachdb.runis its own implicit transaction on Postgres). The shared physical index is still dropped only once the last project undeclares it.Verification
json_extract(...)) insqlite_master, and the shared-index refcount behavior is unchanged.CONCURRENTLYpath end-to-end (declare → query → reconcile → drop). It would fail with "cannot run inside a transaction block" if this were mis-wired, so green proves it.https://claude.ai/code/session_018efxvWw3MRjdtvE5xgBqya
Generated by Claude Code