SQLite VDBE opcode

SeekLT

If cursor P1 refers to an SQL table (B-Tree that uses integer keys), use the value in register P3 as a key.

Jumps: P2 is an instruction address. In the listings here, a jump is drawn as an arc and the address is a link.

An example

1 of the 178 statements we compiled against the sample database use SeekLT. This is the one with the shortest program; the rows that use SeekLT are highlighted.

SELECT * FROM artists WHERE name < 'M' ORDER BY name DESC
addropcodep1p2p3p4p5
0Init01300
1Noop1500
2OpenRead02030
3OpenRead260k(2,,)0
4String8010M0
5SeekLT212110
6DeferredSeek2000
7IdxRowid2200
8Column2030
9Column0240
10ResultRow2300
11Prev2600
12Halt0000
13Transaction00101
14Goto0100

Open it in the EXPLAIN visualizer →

Also in this program: Column, DeferredSeek, Goto, Halt, IdxRowid, Init, Noop, OpenRead, Prev, ResultRow, String8, Transaction.

What the SQLite documentation says

If cursor P1 refers to an SQL table (B-Tree that uses integer keys), use the value in register P3 as a key. If cursor P1 refers to an SQL index, then P3 is the first in an array of P4 registers that are used as an unpacked index key.

Reposition cursor P1 so that it points to the largest entry that is less than the key value. If there are no records less than the key and P2 is not zero, then jump to P2.

This opcode leaves the cursor configured to move in reverse order, from the end toward the beginning. In other words, the cursor is configured to use Prev, not Next.

See also: Found, NotFound, SeekGt, SeekGe, SeekLe

From sqlite.org's list of opcodes for SQLite 3.54.1, in the public domain. Opcodes are not a stable interface and change between releases.

← SeekLE · SeekRowid →