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

Method runMaintenance

src/db/index.ts:679–691  ·  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

677 * CLI has already disarmed its watchdog).
678 */
679 async runMaintenance(): Promise<void> {
680 // In-memory / test databases: nothing worth a worker round-trip.
681 if (!this.dbPath || this.dbPath === ':memory:') {
682 try { this.db.exec('PRAGMA optimize'); } catch { /* ignore */ }
683 try { this.db.exec('PRAGMA wal_checkpoint(PASSIVE)'); } catch { /* ignore */ }
684 return;
685 }
686 await this.runPragmasOffThread(
687 ['PRAGMA analysis_limit=1000', 'PRAGMA optimize', 'PRAGMA wal_checkpoint(PASSIVE)'],
688 // Worker threads unavailable — bounded in-line fallback, no checkpoint.
689 ['PRAGMA analysis_limit=1000', 'PRAGMA optimize']
690 );
691 }
692
693 /**
694 * Run pragmas on a worker thread against its own connection to this DB

Callers 3

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