perf: skip redundant index creation in Neo4jDriver when indices already exist#1288
Open
carlos-alm wants to merge 1 commit intogetzep:mainfrom
Open
perf: skip redundant index creation in Neo4jDriver when indices already exist#1288carlos-alm wants to merge 1 commit intogetzep:mainfrom
carlos-alm wants to merge 1 commit intogetzep:mainfrom
Conversation
Member
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
danielchalef
added a commit
that referenced
this pull request
Mar 2, 2026
…dy exist Add a fast path to build_indices_and_constraints(): query SHOW INDEXES (1 roundtrip) and skip creation if all expected indices already exist. Add an instance-level _indices_verified flag so repeated calls within the same process are free. - All indices exist: 31 queries -> 1 query - Some missing: 31 queries -> 32 queries (1 check + 31 creates) - Second call, same instance: 31 queries -> 0 queries (flag) - SHOW INDEXES fails: graceful fallback to 31 individual queries - delete_existing=True: unchanged behavior
77a1a58 to
0ec8195
Compare
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
Neo4jDriver.build_indices_and_constraints(): querySHOW INDEXES YIELD name(1 roundtrip) and skip creation if all 31 expected indices already exist_indices_verifiedflag so repeated calls within the same process are freeget_neo4j_expected_index_names()from existing CREATE queries (regex over single source of truth — no separate manifest)SHOW INDEXESfails, falls through to the original 31-query behaviordelete_existing=TrueSHOW INDEXESfailsFiles changed
graphiti_core/graph_queries.pyget_neo4j_expected_index_names()+ regexgraphiti_core/driver/neo4j_driver.py_indices_verifiedflagtests/driver/test_neo4j_driver.pyTest plan
get_neo4j_expected_index_names()returns exactly 31 index namesdelete_existing=True→ bypasses fast pathSHOW INDEXESfailure → graceful fallback to individual queries_indices_verifiedflag → second call is free (0 queries)delete_existing=True→ resets verified flag