Skip to content

Commit 78f63eb

Browse files
aksOpsclaude
andcommitted
perf: wait for Neo4j index before edge loading in enrich
Added db.awaitIndexes() call after creating the id index, before starting edge bulk-load. Without this, the first edge batches run without an index on 140K nodes, making MATCH extremely slow. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e05107c commit 78f63eb

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/main/java/io/github/randomcodespace/iq/cli/EnrichCommand.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,20 @@ private int enrichFromCache(AnalysisCache cache, Path root, NumberFormat nf, Ins
225225
}
226226
}
227227

228-
// Create index on id for edge resolution
228+
// Create index on id for edge resolution and wait for it to come online
229+
CliOutput.info(" Creating index on node ID...");
229230
try (Transaction tx = db.beginTx()) {
230231
tx.execute("CREATE INDEX IF NOT EXISTS FOR (n:CodeNode) ON (n.id)");
231232
tx.commit();
232233
}
234+
// Wait for index to be populated (critical for edge MATCH performance)
235+
try (Transaction tx = db.beginTx()) {
236+
tx.execute("CALL db.awaitIndexes(300)");
237+
} catch (Exception e) {
238+
log.debug("Index await returned: {}", e.getMessage());
239+
// Index may already be online, continue
240+
}
241+
CliOutput.info(" Index ready");
233242

234243
// Bulk-load edges
235244
// Use validated edges from flush

0 commit comments

Comments
 (0)