Skip to content

Instantly share code, notes, and snippets.

@borrrden
Created February 1, 2019 00:16
Show Gist options
  • Save borrrden/6cdbbb40a84b45b5a7c387ab273beac7 to your computer and use it in GitHub Desktop.
Save borrrden/6cdbbb40a84b45b5a7c387ab273beac7 to your computer and use it in GitHub Desktop.
Wrong index query explain plan
[
[
0,
"Init",
0,
54,
0,
"",
"00",
"Start at 54"
],
[
1,
"OpenRead",
0,
3,
0,
"5",
"00",
"root=3 iDb=0; kv_default"
],
[
2,
"OpenRead",
1,
3,
0,
"5",
"00",
"root=3 iDb=0; kv_default"
],
[
3,
"Null",
0,
2,
0,
"",
"00",
"r[2]=NULL"
],
[
4,
"Integer",
31,
1,
0,
"",
"00",
"r[1]=31"
],
[
5,
"ReopenIdx",
2,
10,
0,
"k(3,,,)",
"02",
"root=10 iDb=0; IX_OrderHistory_CompleteDate"
],
[
6,
"String8",
0,
4,
0,
"OrderHistory",
"00",
"r[4]='OrderHistory'"
],
[
7,
"Blob",
0,
5,
0,
"",
"00",
"r[5]= (len=0)"
],
[
8,
"SeekGE",
2,
15,
4,
"2",
"00",
"key=r[4..5]"
],
[
9,
"IdxGT",
2,
15,
4,
"2",
"00",
"key=r[4..5]"
],
[
10,
"DeferredSeek",
2,
0,
0,
"[0,0,0,0,0]",
"00",
"Move 0 to 2.rowid if needed"
],
[
11,
"IdxRowid",
2,
3,
0,
"",
"00",
"r[3]=rowid"
],
[
12,
"RowSetTest",
2,
14,
3,
"0",
"00",
"if r[3] in rowset(2) goto 14"
],
[
13,
"Gosub",
1,
32,
0,
"",
"00",
""
],
[
14,
"Next",
2,
9,
0,
"",
"00",
""
],
[
15,
"Column",
2,
0,
6,
"",
"00",
"r[6]="
],
[
16,
"Ne",
7,
31,
6,
"",
"51",
"if r[6]!=r[7] goto 31"
],
[
17,
"ReopenIdx",
2,
10,
0,
"k(3,,,)",
"00",
"root=10 iDb=0; IX_OrderHistory_CompleteDate"
],
[
18,
"Rewind",
2,
31,
0,
"",
"00",
"begin skip-scan on IX_OrderHistory_CompleteDate"
],
[
19,
"Goto",
0,
21,
0,
"",
"00",
""
],
[
20,
"SeekGT",
2,
31,
8,
"1",
"00",
"key=r[8]"
],
[
21,
"Column",
2,
0,
8,
"",
"00",
"r[8]=<expr>"
],
[
22,
"Null",
0,
9,
0,
"",
"00",
"r[9]=NULL"
],
[
23,
"SeekGE",
2,
30,
8,
"2",
"00",
"key=r[8..9]"
],
[
24,
"IdxGT",
2,
30,
8,
"2",
"00",
"key=r[8..9]"
],
[
25,
"DeferredSeek",
2,
0,
0,
"[0,0,0,0,0]",
"00",
"Move 0 to 2.rowid if needed"
],
[
26,
"IdxRowid",
2,
3,
0,
"",
"00",
"r[3]=rowid"
],
[
27,
"RowSetTest",
2,
29,
3,
"-1",
"00",
"if r[3] in rowset(2) goto 29"
],
[
28,
"Gosub",
1,
32,
0,
"",
"00",
""
],
[
29,
"Next",
2,
24,
0,
"",
"00",
""
],
[
30,
"Goto",
0,
20,
0,
"",
"00",
"next skip-scan on IX_OrderHistory_CompleteDate"
],
[
31,
"Goto",
0,
53,
0,
"",
"00",
""
],
[
32,
"Column",
0,
4,
10,
"",
"00",
"r[10]=kv_default.body"
],
[
33,
"Function0",
2,
10,
6,
"fl_value(2)",
"02",
"r[6]=func(r[10..11])"
],
[
34,
"Ne",
7,
52,
6,
"",
"51",
"if r[6]!=r[7] goto 52"
],
[
35,
"Column",
0,
2,
12,
"0",
"00",
"r[12]=kv_default.flags"
],
[
36,
"BitAnd",
13,
12,
6,
"",
"00",
"r[6]=r[13]&r[12]"
],
[
37,
"Ne",
14,
52,
6,
"",
"51",
"if r[6]!=r[14] goto 52"
],
[
38,
"Rewind",
1,
53,
0,
"",
"00",
""
],
[
39,
"Column",
1,
4,
15,
"",
"00",
"r[15]=kv_default.body"
],
[
40,
"Function0",
2,
15,
6,
"fl_value(2)",
"02",
"r[6]=func(r[15..16])"
],
[
41,
"Column",
0,
4,
17,
"",
"00",
"r[17]=kv_default.body"
],
[
42,
"Function0",
2,
17,
12,
"fl_value(2)",
"02",
"r[12]=func(r[17..18])"
],
[
43,
"Ne",
12,
51,
6,
"",
"51",
"if r[6]!=r[12] goto 51"
],
[
44,
"Column",
1,
2,
6,
"0",
"00",
"r[6]=kv_default.flags"
],
[
45,
"BitAnd",
13,
6,
12,
"",
"00",
"r[12]=r[13]&r[6]"
],
[
46,
"Ne",
14,
51,
12,
"",
"51",
"if r[12]!=r[14] goto 51"
],
[
47,
"Column",
1,
4,
20,
"",
"00",
"r[20]=kv_default.body"
],
[
48,
"Function0",
2,
20,
12,
"fl_value(2)",
"02",
"r[12]=func(r[20..21])"
],
[
49,
"Function0",
0,
12,
19,
"fl_result(1)",
"01",
"r[19]=func(r[12])"
],
[
50,
"ResultRow",
19,
1,
0,
"",
"00",
"output=r[19]"
],
[
51,
"Next",
1,
39,
0,
"",
"01",
""
],
[
52,
"Return",
1,
0,
0,
"",
"00",
""
],
[
53,
"Halt",
0,
0,
0,
"",
"00",
""
],
[
54,
"Transaction",
0,
0,
21,
"0",
"01",
"usesStmtJournal=0"
],
[
55,
"String8",
0,
7,
0,
"OrderHistory",
"00",
"r[7]='OrderHistory'"
],
[
56,
"String8",
0,
11,
0,
"Type",
"00",
"r[11]='Type'"
],
[
57,
"Integer",
1,
13,
0,
"",
"00",
"r[13]=1"
],
[
58,
"Integer",
0,
14,
0,
"",
"00",
"r[14]=0"
],
[
59,
"String8",
0,
16,
0,
"CurrentTaskId",
"00",
"r[16]='CurrentTaskId'"
],
[
60,
"String8",
0,
18,
0,
"OrderHistory",
"00",
"r[18]='OrderHistory'"
],
[
61,
"String8",
0,
21,
0,
"RowId",
"00",
"r[21]='RowId'"
],
[
62,
"Goto",
0,
1,
0,
"",
"00",
""
]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment