From e003b265c5709b4a72f88533424d45575d3d1e1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=A1ko=20Hevery?= Date: Thu, 28 Nov 2024 14:27:55 -0800 Subject: [PATCH] chore(insights): add more indexes to spped up DB --- packages/insights/drizzle/meta/_journal.json | 7 +++++++ packages/insights/src/db/schema.ts | 10 +++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/insights/drizzle/meta/_journal.json b/packages/insights/drizzle/meta/_journal.json index a798073ee41..68c3a205f1f 100644 --- a/packages/insights/drizzle/meta/_journal.json +++ b/packages/insights/drizzle/meta/_journal.json @@ -120,6 +120,13 @@ "when": 1732499276499, "tag": "0016_demonic_legion", "breakpoints": true + }, + { + "idx": 17, + "version": "6", + "when": 1732832624307, + "tag": "0017_pink_maestro", + "breakpoints": true } ] } \ No newline at end of file diff --git a/packages/insights/src/db/schema.ts b/packages/insights/src/db/schema.ts index 130c9688b1c..b5a758ff43e 100644 --- a/packages/insights/src/db/schema.ts +++ b/packages/insights/src/db/schema.ts @@ -73,10 +73,18 @@ export const manifestTable = sqliteTable( timestamp: integer('timestamp', { mode: 'timestamp_ms' }).notNull(), }, (table) => ({ - publicApiKeyHashIndex: uniqueIndex('idx_manifests_apiKey_hash').on( + publicApiKeyHashIndex: index('idx_manifests_apiKey_hash').on( table.hash, table.publicApiKey ), + publicApiKeyHashIndex_2: index('idx_manifests_apiKey_hash_2').on( + table.publicApiKey, + table.hash + ), + apiTimestamp: index('idx_manifest_api_timestamp').on( + table.publicApiKey, + table.timestamp + ), publicApiKeyIndex: index('idx_manifests_public_apiKey').on(table.publicApiKey), hashIndex: index('idx_manifests_hash').on(table.hash), })