commit 08c64ae1d277960ea5414b74d5b2ca6488a32efd
parent e3802f016296a7e09f53a76cbbd590db0b0849ff
Author: William Casarin <jb55@jb55.com>
Date: Fri, 13 Dec 2024 20:56:26 -0800
earlier since check in ndb_query_plan_execute_created_at
this avoids a lookup if we dont need it
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/src/nostrdb.c b/src/nostrdb.c
@@ -3181,9 +3181,10 @@ static int ndb_query_plan_execute_created_at(struct ndb_txn *txn,
note_id = *(uint64_t*)v.mv_data;
assert(v.mv_size == 8);
- // TODO(perf): if we are only looking for IDs and have no other
- // condition, then we can use the ID in the index without
- // looking up the note. For now we always look up the note
+ // don't continue the scan if we're below `since`
+ if (pkey->timestamp < since)
+ break;
+
if (!(note = ndb_get_note_by_key(txn, note_id, ¬e_size)))
goto next;
@@ -3191,10 +3192,6 @@ static int ndb_query_plan_execute_created_at(struct ndb_txn *txn,
if (!ndb_filter_matches_with(filter, note, 0))
goto next;
- // don't continue the scan if we're below `since`
- if (pkey->timestamp < since)
- break;
-
ndb_query_result_init(&res, note, (uint64_t)note_size, note_id);
if (!push_query_result(results, &res))
break;