Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Updated testing of cursor-hints. Remove the test_cursorhint.c file and associated logic in the core and do tests based purely on the newly enhanced EXPLAIN output. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | cursor-hints |
Files: | files | file ages | folders |
SHA1: |
bf383e665a191a4f33a540d1240960a9 |
User & Date: | drh 2015-08-14 20:08:13.528 |
Context
2015-08-14
| ||
23:57 | Always provide the BTREE_BULKLOAD hint, even when SQLITE_ENABLE_CURSOR_HINTS is not defined, as that hint gives a 4% performance increase. (check-in: 83a844357e user: drh tags: cursor-hints) | |
20:08 | Updated testing of cursor-hints. Remove the test_cursorhint.c file and associated logic in the core and do tests based purely on the newly enhanced EXPLAIN output. (check-in: bf383e665a user: drh tags: cursor-hints) | |
18:50 | Fix the cursor hint mechanism so that it does the right thing for indexed lookups. (check-in: 581e3d4988 user: drh tags: cursor-hints) | |
Changes
Changes to main.mk.
︙ | ︙ | |||
258 259 260 261 262 263 264 | $(TOP)/src/test9.c \ $(TOP)/src/test_autoext.c \ $(TOP)/src/test_async.c \ $(TOP)/src/test_backup.c \ $(TOP)/src/test_blob.c \ $(TOP)/src/test_btree.c \ $(TOP)/src/test_config.c \ | < | 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | $(TOP)/src/test9.c \ $(TOP)/src/test_autoext.c \ $(TOP)/src/test_async.c \ $(TOP)/src/test_backup.c \ $(TOP)/src/test_blob.c \ $(TOP)/src/test_btree.c \ $(TOP)/src/test_config.c \ $(TOP)/src/test_demovfs.c \ $(TOP)/src/test_devsym.c \ $(TOP)/src/test_fs.c \ $(TOP)/src/test_func.c \ $(TOP)/src/test_hexio.c \ $(TOP)/src/test_init.c \ $(TOP)/src/test_intarray.c \ |
︙ | ︙ |
Changes to src/tclsqlite.c.
︙ | ︙ | |||
3735 3736 3737 3738 3739 3740 3741 | extern int Sqlitetest6_Init(Tcl_Interp*); extern int Sqlitetest7_Init(Tcl_Interp*); extern int Sqlitetest8_Init(Tcl_Interp*); extern int Sqlitetest9_Init(Tcl_Interp*); extern int Sqlitetestasync_Init(Tcl_Interp*); extern int Sqlitetest_autoext_Init(Tcl_Interp*); extern int Sqlitetest_blob_Init(Tcl_Interp*); | < | 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 | extern int Sqlitetest6_Init(Tcl_Interp*); extern int Sqlitetest7_Init(Tcl_Interp*); extern int Sqlitetest8_Init(Tcl_Interp*); extern int Sqlitetest9_Init(Tcl_Interp*); extern int Sqlitetestasync_Init(Tcl_Interp*); extern int Sqlitetest_autoext_Init(Tcl_Interp*); extern int Sqlitetest_blob_Init(Tcl_Interp*); extern int Sqlitetest_demovfs_Init(Tcl_Interp *); extern int Sqlitetest_func_Init(Tcl_Interp*); extern int Sqlitetest_hexio_Init(Tcl_Interp*); extern int Sqlitetest_init_Init(Tcl_Interp*); extern int Sqlitetest_malloc_Init(Tcl_Interp*); extern int Sqlitetest_mutex_Init(Tcl_Interp*); extern int Sqlitetestschema_Init(Tcl_Interp*); |
︙ | ︙ | |||
3781 3782 3783 3784 3785 3786 3787 | Sqlitetest6_Init(interp); Sqlitetest7_Init(interp); Sqlitetest8_Init(interp); Sqlitetest9_Init(interp); Sqlitetestasync_Init(interp); Sqlitetest_autoext_Init(interp); Sqlitetest_blob_Init(interp); | < < | 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 | Sqlitetest6_Init(interp); Sqlitetest7_Init(interp); Sqlitetest8_Init(interp); Sqlitetest9_Init(interp); Sqlitetestasync_Init(interp); Sqlitetest_autoext_Init(interp); Sqlitetest_blob_Init(interp); Sqlitetest_demovfs_Init(interp); Sqlitetest_func_Init(interp); Sqlitetest_hexio_Init(interp); Sqlitetest_init_Init(interp); Sqlitetest_malloc_Init(interp); Sqlitetest_mutex_Init(interp); Sqlitetestschema_Init(interp); |
︙ | ︙ |
Deleted src/test_cursorhint.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to src/vdbe.c.
︙ | ︙ | |||
6566 6567 6568 6569 6570 6571 6572 | VdbeCursor *pC; assert( pOp->p1>=0 && pOp->p1<p->nCursor ); assert( pOp->p4type==P4_EXPR ); pC = p->apCsr[pOp->p1]; if( pC ){ sqlite3BtreeCursorHint(pC->pCursor, BTREE_HINT_RANGE, pOp->p4.pExpr, aMem); | < < < < | 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 | VdbeCursor *pC; assert( pOp->p1>=0 && pOp->p1<p->nCursor ); assert( pOp->p4type==P4_EXPR ); pC = p->apCsr[pOp->p1]; if( pC ){ sqlite3BtreeCursorHint(pC->pCursor, BTREE_HINT_RANGE, pOp->p4.pExpr, aMem); } break; } #endif /* SQLITE_ENABLE_CURSOR_HINTS */ /* Opcode: Noop * * * * * ** |
︙ | ︙ |
Changes to test/cursorhint.test.
︙ | ︙ | |||
12 13 14 15 16 17 18 | # set testdir [file dirname $argv0] source $testdir/tester.tcl set testprefix cursorhint do_execsql_test 1.0 { | | | | | | | > > > > > | > > | > | | < < < > > > | | < < > > > > > | > > > | | > | > > > > > > > > > > > > > > | | > > > | | > | | > | > | | < > > > > > | < | < > > > > | > | > | > | > > > > | < > > > > | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | # set testdir [file dirname $argv0] source $testdir/tester.tcl set testprefix cursorhint do_execsql_test 1.0 { CREATE TABLE t1(a,b,c,d); CREATE TABLE t2(x,y,z); INSERT INTO t1(a,b) VALUES(10, 15); INSERT INTO t1(a,b) VALUES(20, 25); INSERT INTO t2(x,y) VALUES('ten', 'fifteen'); INSERT INTO t2(x,y) VALUES('twenty', 'twentyfive'); CREATE TABLE t3(id TEXT PRIMARY KEY, a, b, c, d) WITHOUT ROWID; INSERT INTO t3(id,a,b,c,d) SELECT rowid, a, b, c, d FROM t1; PRAGMA automatic_index = 0; } # Run EXPLAIN on $sql. Return a list of P4 values for all $opcode # opcodes. # proc p4_of_opcode {db opcode sql} { set res {} $db eval "EXPLAIN $sql" x { if {$x(opcode)==$opcode} {lappend res $x(p4)} } return $res } # Run EXPLAIN on $sql. Return a list of P5 values for all $opcode # opcodes that contain regexp $comment in their comment # proc p5_of_opcode {db opcode comment sql} { set res {} $db eval "EXPLAIN $sql" x { if {$x(opcode)==$opcode && [regexp $comment $x(comment)]} { lappend res $x(p5) } } return $res } # Verify that when t1 is in the outer loop and t2 is in the inner loop, # no cursor hints occur for t1 (since it is a full table scan) but that # each t2 access has a cursor hint based on the current t1.a value. # do_test 1.1 { p4_of_opcode db CursorHint { SELECT * FROM t1 CROSS JOIN t2 WHERE a=x } } {/(r*==c0)/} do_test 1.2 { p5_of_opcode db OpenRead . { SELECT * FROM t1 CROSS JOIN t2 WHERE a=x } } {00 00} # Do the same test the other way around. # do_test 2.1 { p4_of_opcode db CursorHint { SELECT * FROM t2 CROSS JOIN t1 WHERE a=x } } {/(c0==r*)/} do_test 2.2 { p5_of_opcode db OpenRead . { SELECT * FROM t2 CROSS JOIN t1 WHERE a=x } } {00 00} # Various expressions captured by CursorHint # do_test 3.1 { p4_of_opcode db CursorHint { SELECT * FROM t1 WHERE a=15 AND c=22 AND rowid!=98 } } {/(c0==15).*(c2==22).*(rowid!=98)/} do_test 3.2 { p4_of_opcode db CursorHint { SELECT * FROM t3 WHERE a<15 AND b>22 AND id!=98 } } {/(c1<15).*(c2>22).*(c0!=98)/} # Indexed queries # do_test 4.1 { db eval { CREATE INDEX t1bc ON t1(b,c); CREATE INDEX t2yz ON t2(y,z); } p4_of_opcode db CursorHint { SELECT * FROM t1 WHERE b>11; } } {/(c0>11)/} do_test 4.2 { p5_of_opcode db OpenRead . { SELECT * FROM t1 WHERE b>11; } } {02 00} do_test 4.3 { p4_of_opcode db CursorHint { SELECT c FROM t1 WHERE b>11; } } {/(c0>11)/} do_test 4.4 { p5_of_opcode db OpenRead . { SELECT c FROM t1 WHERE b>11; } } {00} finish_test |