From abbce3dd3993a1ced9932e5786a2b3b3dacab199 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 15 May 2026 10:37:54 +0000 Subject: [PATCH] perf: batch PRAGMA statements to optimize getPragmas Batched PRAGMA queries into a single `executeQuery` call by joining them with semicolons and newlines to eliminate multiple async overheads. --- src/core/engine/wasm/WasmDatabaseEngine.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/core/engine/wasm/WasmDatabaseEngine.ts b/src/core/engine/wasm/WasmDatabaseEngine.ts index 5590505..f80d4ec 100644 --- a/src/core/engine/wasm/WasmDatabaseEngine.ts +++ b/src/core/engine/wasm/WasmDatabaseEngine.ts @@ -920,11 +920,12 @@ export class WasmDatabaseEngine implements DatabaseOperations { ]; const result: Record = {}; + const query = pragmasToFetch.map(pragma => `PRAGMA ${pragma};`).join('\n'); + const res = await this.executeQuery(query); - for (const pragma of pragmasToFetch) { - const res = await this.executeQuery(`PRAGMA ${pragma}`); - if (res[0]?.rows?.[0]) { - result[pragma] = res[0].rows[0][0]; + for (let i = 0; i < pragmasToFetch.length; i++) { + if (res[i]?.rows?.[0]) { + result[pragmasToFetch[i]] = res[i].rows[0][0]; } }