mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-26 09:02:11 +03:00
* perf(db): add temp_store=MEMORY pragma to SQLite init Store temp tables/indices in memory instead of disk for faster query execution (GROUP BY, ORDER BY, subquery materialization). The two other optimized PRAGMAs (synchronous=NORMAL, cache_size=-16384) were already set. * test(db): add temp_store MEMORY pragma test Verifies PRAGMA temp_store = 2 (MEMORY) after initDb() runs. --------- Co-authored-by: oyi77 <oyi77@users.noreply.github.com>
22 lines
852 B
TypeScript
22 lines
852 B
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import fs from "node:fs";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
|
|
const TEST_DATA_DIR = fs.mkdtempSync(path.join(os.tmpdir(), "omr-temp-store-"));
|
|
process.env.DATA_DIR = TEST_DATA_DIR;
|
|
process.env.API_KEY_SECRET = "test-temp-store-secret";
|
|
|
|
const { getDbInstance } = await import("../../src/lib/db/core.ts");
|
|
|
|
test("temp_store pragma is 2 (MEMORY) after initDb", () => {
|
|
// The database singleton should already have the pragma set by initDb().
|
|
// This test confirms the runtime respects the setting.
|
|
const db = getDbInstance();
|
|
const val: unknown = db.pragma("temp_store", { simple: true });
|
|
assert.ok(typeof val === "number");
|
|
// 2 = MEMORY (set by the new PRAGMA in initDb)
|
|
assert.equal(val, 2, "expected temp_store=2 (MEMORY) after initDb");
|
|
});
|