MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / runMaintenance

Method runMaintenance

src/db/index.ts:906–918  ·  view source on GitHub ↗

* Lightweight maintenance to run after bulk writes (indexAll, sync). * Two operations: * * - `PRAGMA optimize` — incremental ANALYZE; SQLite only re-analyzes * tables whose row counts changed materially since the last * ANALYZE. Without it, the query planner has no statistic

()

Source from the content-addressed store, hash-verified

904 * CLI has already disarmed its watchdog).
905 */
906 async runMaintenance(): Promise<void> {
907 // In-memory / test databases: nothing worth a worker round-trip.
908 if (!this.dbPath || this.dbPath === ':memory:') {
909 try { this.db.exec('PRAGMA optimize'); } catch { /* ignore */ }
910 try { this.db.exec('PRAGMA wal_checkpoint(PASSIVE)'); } catch { /* ignore */ }
911 return;
912 }
913 await this.runPragmasOffThread(
914 ['PRAGMA analysis_limit=1000', 'PRAGMA optimize', 'PRAGMA wal_checkpoint(PASSIVE)'],
915 // Worker threads unavailable — bounded in-line fallback, no checkpoint.
916 ['PRAGMA analysis_limit=1000', 'PRAGMA optimize']
917 );
918 }
919
920 /**
921 * Run pragmas on a worker thread against its own connection to this DB

Callers 4

indexAllMethod · 0.80
syncMethod · 0.80
db-perf.test.tsFile · 0.80

Calls 2

runPragmasOffThreadMethod · 0.95
execMethod · 0.65

Tested by

no test coverage detected