import type Database from "better-sqlite3"; /** * Slow-query threshold, in milliseconds. * * Measured, not guessed. Against the live 22 MB `cache.db` on this machine * (583 conversations, 38 717 index rows, warm page cache), 3 600 read samples * across the twelve statements the hot paths actually run gave p50 0.03 ms, * p99 0.87 ms, p99.9 1.43 ms, max 1.83 ms; 1 200 write samples gave p99 * 0.09 ms with rare WAL-checkpoint spikes to 4.37 ms. So *every* healthy query * on this machine finishes inside ~4.4 ms, and the checkpoint spikes are the * only thing anywhere near that. * * 35 ms sits two anchors above that: it is 8x the slowest healthy operation * ever observed, so checkpoint spikes can never page anyone, and it is more * than the 34 ms *end-to-end* time of the fastest complete conversation fetch * measured on this box. A query crossing it therefore cost more on its own * than an entire healthy request — which is the point at which a warn line is * worth the bytes it occupies in the log. * * Override with `THREADBASE_DB_SLOW_QUERY_MS`; <= 0 disables slow logging. */ export declare const DEFAULT_SLOW_QUERY_MS = 35; /** * Time every `.get()` / `.all()` / `.run()` on every statement this connection * prepares. * * Wrapping `prepare` is what makes this one edit per database instead of one * per query: `better-sqlite3` is synchronous, so a call's wall time *is* its * cost, and every statement in the process — the 45 in ConversationCache, the * 4 in RuntimeStore, and the ~40 more inside the repositories that share these * handles — is created here. Measured overhead is +0.09 µs on an 8.9 µs call * (~1%), which is why it is always on rather than behind a flag. * * Only the three terminal methods are replaced, as own properties; `iterate`, * `pluck`, `raw`, `columns` and `bind` keep resolving to the prototype * untouched. A statement that throws is not recorded — the error surfaces on * its own path. */ export declare function instrumentDatabase(db: Database.Database, options?: { slowMs?: number; }): Database.Database; /** * Name the statements in a `{ name: Statement }` bag after their keys, so a * slow-query line reads `getMessageIndexWindow` rather than * `select:conversation_message_index`. * * Separate from `instrumentDatabase` because `prepare` cannot know the key its * result is about to be assigned to. Statements from a connection that was * never instrumented are skipped. */ export declare function labelStatements(statements: object): void; //# sourceMappingURL=query-timing.d.ts.map