nostrdb: 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>
This commit is contained in:
committed by
Daniel D’Aquino
parent
d24a3f0ce5
commit
2c4728508b
@@ -3181,9 +3181,10 @@ static int ndb_query_plan_execute_created_at(struct ndb_txn *txn,
|
|||||||
note_id = *(uint64_t*)v.mv_data;
|
note_id = *(uint64_t*)v.mv_data;
|
||||||
assert(v.mv_size == 8);
|
assert(v.mv_size == 8);
|
||||||
|
|
||||||
// TODO(perf): if we are only looking for IDs and have no other
|
// don't continue the scan if we're below `since`
|
||||||
// condition, then we can use the ID in the index without
|
if (pkey->timestamp < since)
|
||||||
// looking up the note. For now we always look up the note
|
break;
|
||||||
|
|
||||||
if (!(note = ndb_get_note_by_key(txn, note_id, ¬e_size)))
|
if (!(note = ndb_get_note_by_key(txn, note_id, ¬e_size)))
|
||||||
goto next;
|
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))
|
if (!ndb_filter_matches_with(filter, note, 0))
|
||||||
goto next;
|
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);
|
ndb_query_result_init(&res, note, (uint64_t)note_size, note_id);
|
||||||
if (!push_query_result(results, &res))
|
if (!push_query_result(results, &res))
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user