perf(db): batch node lookups, fix insertNode cache, run maintenance after writes (#108)
Batch getNodesByIds to collapse N+1 reads in graph traversal, invalidate the insertNode LRU cache so INSERT OR REPLACE doesn't serve a stale row, and run incremental PRAGMA optimize + passive WAL checkpoint after bulk writes. Closes #108
This commit is contained in:
@@ -347,6 +347,12 @@ export class CodeGraph {
|
||||
});
|
||||
}
|
||||
|
||||
// Refresh planner stats + checkpoint the WAL after bulk writes.
|
||||
// Cheap and non-blocking; never load-bearing for correctness.
|
||||
if (result.success && result.filesIndexed > 0) {
|
||||
this.db.runMaintenance();
|
||||
}
|
||||
|
||||
return result;
|
||||
} finally {
|
||||
this.fileLock.release();
|
||||
@@ -428,6 +434,11 @@ export class CodeGraph {
|
||||
}
|
||||
}
|
||||
|
||||
// Refresh planner stats + checkpoint the WAL after bulk writes.
|
||||
if (result.filesAdded > 0 || result.filesModified > 0 || result.filesRemoved > 0) {
|
||||
this.db.runMaintenance();
|
||||
}
|
||||
|
||||
return result;
|
||||
} finally {
|
||||
this.fileLock.release();
|
||||
|
||||
Reference in New Issue
Block a user