From 79f514a843773bab85a03fc1870b3ac0553a8fda Mon Sep 17 00:00:00 2001 From: Lukasz Modzelewski Date: Thu, 19 Mar 2026 10:28:41 +0100 Subject: [PATCH] Use json_each JOIN for multiGet instead of IN clause --- lib/storage/providers/SQLiteProvider.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/storage/providers/SQLiteProvider.ts b/lib/storage/providers/SQLiteProvider.ts index afbc0f405..65caa56c5 100644 --- a/lib/storage/providers/SQLiteProvider.ts +++ b/lib/storage/providers/SQLiteProvider.ts @@ -107,9 +107,8 @@ const provider: StorageProvider = { throw new Error('Store is not initialized!'); } - const placeholders = keys.map(() => '?').join(','); - const command = `SELECT record_key, valueJSON FROM keyvaluepairs WHERE record_key IN (${placeholders});`; - return provider.store.executeAsync(command, keys).then(({rows}) => { + const command = `SELECT kv.record_key, kv.valueJSON FROM keyvaluepairs kv INNER JOIN json_each(?) je ON kv.record_key = je.value;`; + return provider.store.executeAsync(command, [JSON.stringify(keys)]).then(({rows}) => { // eslint-disable-next-line no-underscore-dangle const result = rows?._array.map((row) => [row.record_key, JSON.parse(row.valueJSON)]); return (result ?? []) as StorageKeyValuePair[];