From 2d3a35fe30e70d4af125de2c501cc90b633a0950 Mon Sep 17 00:00:00 2001 From: Greg Heartsfield Date: Wed, 1 Feb 2023 06:46:35 -0600 Subject: [PATCH] perf: force event hash index if filter uses ids --- src/repo/sqlite.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/repo/sqlite.rs b/src/repo/sqlite.rs index 4d12b7b..7463de1 100644 --- a/src/repo/sqlite.rs +++ b/src/repo/sqlite.rs @@ -658,6 +658,9 @@ impl NostrRepo for SqliteRepo { /// Decide if there is an index that should be used explicitly fn override_index(f: &ReqFilter) -> Option { + if f.ids.is_some() { + return Some("event_hash_index".into()); + } // queries for multiple kinds default to kind_index, which is // significantly slower than kind_created_at_index. if let Some(ks) = &f.kinds {