From c3adafa860661d411a0ce6617dbc0745206f53bc Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 21 Mar 2024 19:22:40 -0500 Subject: [PATCH] EventsDB: use a subquery instead of a join --- src/storages/events-db.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/storages/events-db.ts b/src/storages/events-db.ts index 75e45b4..8809648 100644 --- a/src/storages/events-db.ts +++ b/src/storages/events-db.ts @@ -200,9 +200,8 @@ class EventsDB implements NStore { ) as { key: 'domain'; value: string } | undefined)?.value; if (domain) { - query = query - .innerJoin('pubkey_domains', 'pubkey_domains.pubkey', 'events.pubkey') - .where('pubkey_domains.domain', '=', domain); + query = query.where('events.pubkey', 'in', (eb) => + eb.selectFrom('pubkey_domains').select('pubkey').where('domain', '=', domain)); } const q = tokens.filter((t) =>