From 185f9e7abbceea632effce967efbaf6d845e33d5 Mon Sep 17 00:00:00 2001 From: Greg Heartsfield Date: Sun, 12 Feb 2023 15:43:22 -0600 Subject: [PATCH] feat: improved query performance when looking for deletion events (improves event insert time) --- src/repo/sqlite.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/repo/sqlite.rs b/src/repo/sqlite.rs index 9f9d895..dd15215 100644 --- a/src/repo/sqlite.rs +++ b/src/repo/sqlite.rs @@ -223,7 +223,7 @@ impl SqliteRepo { // check if a deletion has already been recorded for this event. // Only relevant for non-deletion events let del_count = tx.query_row( - "SELECT e.id FROM event e LEFT JOIN tag t ON e.id=t.event_id WHERE e.author=? AND t.name='e' AND e.kind=5 AND t.value=? LIMIT 1;", + "SELECT e.id FROM event e WHERE e.author=? AND e.id IN (SELECT t.event_id FROM tag t WHERE t.name='e' AND t.kind=5 AND t.value=?) LIMIT 1;", params![pubkey_blob, e.id], |row| row.get::(0)); // check if a the query returned a result, meaning we should // hid the current event