SQLite VDBE opcode

Explain

This is the same as Noop during normal query execution.

An example

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

SELECT a.name, b.title FROM artists a LEFT JOIN albums b ON b.artist_id = a.id
addropcodep1p2p3p4p5
0Init03100
1OpenRead260k(2,,)0
2OpenRead13040
3Rewind230100
4Once01600
5OpenAutoindex330k(3,B,,)0
6Explain600BLOOM FILTER ON b (artist_id=?)0
7Blob10000100
8Rewind11600
9Column1130
10Column1240
11Rowid1500
12MakeRecord3320
13FilterAdd10310
14IdxInsert32016
15Next1903
16Integer0600
17IdxRowid2700
18Filter126710
19SeekGE326710
20IdxGT326710
21Integer1600
22Column2080
23Column3190
24ResultRow8200
25Next32000
26IfPos62900
27NullRow3000
28Goto02100
29Next2401
30Halt0000
31Transaction00101
32Goto0100

Open it in the EXPLAIN visualizer →

Also in this program: Blob, Column, Filter, FilterAdd, Goto, Halt, IdxGT, IdxInsert, IdxRowid, IfPos, Init, Integer, MakeRecord, Next, NullRow, Once, OpenAutoindex, OpenRead, ResultRow, Rewind, Rowid, SeekGE, Transaction.

What the SQLite documentation says

This is the same as Noop during normal query execution. The purpose of this opcode is to hold information about the query plan for the purpose of EXPLAIN QUERY PLAN output.

The P4 value is human-readable text that describes the query plan element. Something like "SCAN t1" or "SEARCH t2 USING INDEX t2x1".

The P1 value is the ID of the current element and P2 is the parent element for the case of nested query plan elements. If P2 is zero then this element is a top-level element.

For loop elements, P3 is the estimated code of each invocation of this element.

As with all opcodes, the meanings of the parameters for Explain are subject to change from one release to the next. Applications should not attempt to interpret or use any of the information contained in the Explain opcode. The information provided by this opcode is intended for testing and debugging use only.

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.

← Expire · Filter →