From e9b8b0265d86f6f4874f6a75ddcef5413c3bcb9e Mon Sep 17 00:00:00 2001 From: Nikita Sivukhin Date: Tue, 30 Sep 2025 16:16:04 +0400 Subject: [PATCH] skip NULL in case of search over index --- core/translate/main_loop.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/core/translate/main_loop.rs b/core/translate/main_loop.rs index eb1c874e9..6b5107259 100644 --- a/core/translate/main_loop.rs +++ b/core/translate/main_loop.rs @@ -1148,9 +1148,19 @@ fn emit_seek( // depending on the iteration direction. match seek_def.iter_dir { IterationDirection::Forwards => { - program.emit_insn(Insn::Rewind { + // the seek always has some bound condition over indexed column (e.g. c < ?, c >= ?, ...) + // so, NULL always must be filtered out + // (note, that complex filters like c < ? OR c IS NULL will produce Scan operation instead of Search) + program.emit_insn(Insn::Null { + dest: start_reg, + dest_end: None, + }); + program.emit_insn(Insn::SeekGT { + is_index, cursor_id: seek_cursor_id, - pc_if_empty: loop_end, + start_reg, + num_regs: 1, + target_pc: loop_end, }); } IterationDirection::Backwards => {