DeferredSeek
P1 is an open index cursor and P3 is a cursor on the corresponding table.
An example
23 of the 178 statements we compiled against the sample database use DeferredSeek. This is the one with the shortest program; the rows that use DeferredSeek are highlighted.
SELECT * FROM artists WHERE name < 'M' ORDER BY name DESC
| addr | opcode | p1 | p2 | p3 | p4 | p5 |
|---|---|---|---|---|---|---|
| 0 | Init | 0 | 13 | 0 | 0 | |
| 1 | Noop | 1 | 5 | 0 | 0 | |
| 2 | OpenRead | 0 | 2 | 0 | 3 | 0 |
| 3 | OpenRead | 2 | 6 | 0 | k(2,,) | 0 |
| 4 | String8 | 0 | 1 | 0 | M | 0 |
| 5 | SeekLT | 2 | 12 | 1 | 1 | 0 |
| 6 | DeferredSeek | 2 | 0 | 0 | 0 | |
| 7 | IdxRowid | 2 | 2 | 0 | 0 | |
| 8 | Column | 2 | 0 | 3 | 0 | |
| 9 | Column | 0 | 2 | 4 | 0 | |
| 10 | ResultRow | 2 | 3 | 0 | 0 | |
| 11 | Prev | 2 | 6 | 0 | 0 | |
| 12 | Halt | 0 | 0 | 0 | 0 | |
| 13 | Transaction | 0 | 0 | 1 | 0 | 1 |
| 14 | Goto | 0 | 1 | 0 | 0 |
Open it in the EXPLAIN visualizer →
Also in this program: Column, Goto, Halt, IdxRowid, Init, Noop, OpenRead, Prev, ResultRow, SeekLT, String8, Transaction.
What the SQLite documentation says
P1 is an open index cursor and P3 is a cursor on the corresponding table. This opcode does a deferred seek of the P3 table cursor to the row that corresponds to the current row of P1.
This is a deferred seek. Nothing actually happens until the cursor is used to read a record. That way, if no reads occur, no unnecessary I/O happens.
P4 may be an array of integers (type P4_INTARRAY) containing one entry for each column in the P3 table. If array entry a(i) is non-zero, then reading column a(i)-1 from cursor P3 is equivalent to performing the deferred seek and then reading column i from P1. This information is stored in P3 and used to redirect reads against P3 over to P1, thus possibly avoiding the need to seek and read cursor P3.
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.
← DecrJumpZero · Delete →