Skip to content

Instantly share code, notes, and snippets.

@mattrco
Created October 10, 2012 19:52
Show Gist options
  • Save mattrco/3867983 to your computer and use it in GitHub Desktop.
Save mattrco/3867983 to your computer and use it in GitHub Desktop.
SQLite Explain Insert
sqlite> EXPLAIN INSERT INTO names VALUES (1, 'Holly');
addr opcode p1 p2 p3 p4 p5 comment
---- ------------- ---- ---- ---- ------------- -- -------------
0 Trace 0 0 0 00
1 Goto 0 10 0 00 Jump to address P2 (line 10 here, so starts transaction)
2 OpenWrite 0 2 0 2 00 Open a read/write cursor (only one permitted)
3 NewRowid 0 1 0 00 Record number, in this case specified in our INSERT statement
4 Integer 1 2 0 00
5 String8 0 3 0 Holly 00
6 MakeRecord 2 2 4 dc 00 Convert P2 registers beginning from P1 into a database record
7 Insert 0 4 1 names 1b Write entry to table
8 Close 0 0 0 00 Close cursor
9 Halt 0 0 0 00
10 Transaction 0 1 0 00
11 VerifyCookie 0 1 0 00
12 TableLock 0 2 1 names 00
13 Goto 0 2 0 00 Jump to address P2 (line 2 here, the OpenWrite command)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment