From 0403cb3012059c27bb6b793e9fc57b16116dc439 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 14 Aug 2015 23:57:04 +0000 Subject: [PATCH] Always provide the BTREE_BULKLOAD hint, even when SQLITE_ENABLE_CURSOR_HINTS is not defined, as that hint gives a 4% performance increase. FossilOrigin-Name: 83a844357e132683ab3d88eee0fe32a8beeb6662 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/btree.c | 28 +++++++++------------------- src/btree.h | 18 ++++++------------ src/vdbe.c | 6 ++++-- 5 files changed, 28 insertions(+), 42 deletions(-) diff --git a/manifest b/manifest index 794278256f..931701bf6b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Updated\stesting\sof\scursor-hints.\s\sRemove\sthe\stest_cursorhint.c\sfile\sand\nassociated\slogic\sin\sthe\score\sand\sdo\stests\sbased\spurely\son\sthe\snewly\senhanced\nEXPLAIN\soutput. -D 2015-08-14T20:08:13.528 +C Always\sprovide\sthe\sBTREE_BULKLOAD\shint,\seven\swhen\sSQLITE_ENABLE_CURSOR_HINTS\nis\snot\sdefined,\sas\sthat\shint\sgives\sa\s4%\sperformance\sincrease. +D 2015-08-14T23:57:04.215 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2fc9ca6bf5949d415801c007ed3004a4bdb7c380 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -277,8 +277,8 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 4d9134dc988a87838c06056c89c0e8c4700a0452 F src/bitvec.c d1f21d7d91690747881f03940584f4cc548c9d3d F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 -F src/btree.c 84ae3d2d5b0f74257ecb95badc9c9516e6bf6cb6 -F src/btree.h a1f058c495f5020068b864b67b89b13896174137 +F src/btree.c b8083a37c09df6a30af497086d7ba05c1526d359 +F src/btree.h 6310645beddbd3eef89fa9b6d1062065976a93c8 F src/btreeInt.h 8177c9ab90d772d6d2c6c517e05bed774b7c92c0 F src/build.c 4acc35c4e0a2d94c906abd164568cd6fc989cfbb F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 @@ -398,7 +398,7 @@ F src/update.c 487747b328b7216bb7f6af0695d6937d5c9e605f F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c F src/util.c bc9dd64b5db544218b871b66243871c202b2781f F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701 -F src/vdbe.c 882cac44eb4f53d18e31c79fc1741d400016f867 +F src/vdbe.c 4dbcceb38f5c3e42c0725a56e7c76eb12adedebb F src/vdbe.h 529bb4a7bedcd28dccba5abb3927e3c5cb70a832 F src/vdbeInt.h 7258d75fc2dad0bccdef14d7d8d2fd50fd1bf2d2 F src/vdbeapi.c adabbd66eb2e3a10f3998485ee0be7e326d06ee4 @@ -1374,7 +1374,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 581e3d4988e98975fea5daaeb9f854c54a4976b7 -R 32fb6312a84d28df618932a2d55ba493 +P bf383e665a191a4f33a540d1240960a922e22813 +R 87aadf49a7545642a0a9fb9a1d94cce7 U drh -Z 247ce995f99250cbca60587acaa0c7c9 +Z 44853a09e3a1d8da8995535278d599e8 diff --git a/manifest.uuid b/manifest.uuid index 00b59df147..9c7ac55d4b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bf383e665a191a4f33a540d1240960a922e22813 \ No newline at end of file +83a844357e132683ab3d88eee0fe32a8beeb6662 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 0ef1a0555d..18a22de93c 100644 --- a/src/btree.c +++ b/src/btree.c @@ -837,36 +837,26 @@ int sqlite3BtreeCursorRestore(BtCursor *pCur, int *pDifferentRow){ return SQLITE_OK; } -#ifdef SQLITE_ENABLE_CURSOR_HINTS /* ** Provide hints to the cursor. The particular hint given (and the type ** and number of the varargs parameters) is determined by the eHintType ** parameter. See the definitions of the BTREE_HINT_* macros for details. -** -** Hints are not (currently) used by the native SQLite implementation. -** This mechanism is provided for systems that substitute an alternative -** storage engine. */ void sqlite3BtreeCursorHint(BtCursor *pCur, int eHintType, ...){ va_list ap; va_start(ap, eHintType); - switch( eHintType ){ - case BTREE_HINT_FLAGS: { - pCur->hints = va_arg(ap, unsigned int); - assert( pCur->hints==BTREE_SEEK_EQ || pCur->hints==BTREE_BULKLOAD - || pCur->hints==0 ); - break; - } - case BTREE_HINT_RANGE: { - (void)va_arg(ap, Expr*); - (void)va_arg(ap, struct Mem*); - /* Range expression not used in this implementation */ - break; - } +#ifdef SQLITE_ENABLE_CURSOR_HINTS + if( eHintType==BTREE_HINT_FLAGS ) +#else + assert( eHintType==BTREE_HINT_FLAGS ); +#endif + { + pCur->hints = va_arg(ap, unsigned int); + assert( pCur->hints==BTREE_SEEK_EQ || pCur->hints==BTREE_BULKLOAD + || pCur->hints==0 ); } va_end(ap); } -#endif /* SQLITE_ENABLE_CURSOR_HINTS */ #ifndef SQLITE_OMIT_AUTOVACUUM /* diff --git a/src/btree.h b/src/btree.h index de6f3b9467..e0c9ab0ab1 100644 --- a/src/btree.h +++ b/src/btree.h @@ -153,14 +153,6 @@ int sqlite3BtreeNewDb(Btree *p); ** Kinds of hints that can be passed into the sqlite3BtreeCursorHint() ** interface. ** -** Note that cursor hints are not used by the canonical SQLite b-tree -** ayer. Cursor hints are provided so that systems that substitute their -** on custom b-tree layer can have access to additional information that might -** boost performance. Hints are only provided if SQLite is compiled with -** SQLITE_ENABLE_CURSOR_HINTS. The hinting interface is undocumented -** (except for comments such as this) and is subject to change from one -** release of SQLite to the next. -** ** BTREE_HINT_FLAGS (arguments: unsigned int) ** ** Some combinatation of BTREE_BULKLOAD and BTREE_SEEK_EQ flags. The @@ -184,6 +176,11 @@ int sqlite3BtreeNewDb(Btree *p); ** to prefetch content from remote machines - to provide those ** implementations with limits on what needs to be prefetched and thereby ** reduce network bandwidth. +** +** Note that BTREE_HINT_FLAGS with BTREE_BULKLOAD is the only hint used by +** standard SQLite. The other hints are provided for extentions that use +** the SQLite parser and code generator but substitute their own storage +** engine. */ #define BTREE_HINT_FLAGS 1 /* Set flags indicating cursor usage */ #define BTREE_HINT_RANGE 2 /* Range constraints on queries */ @@ -204,10 +201,6 @@ int sqlite3BtreeNewDb(Btree *p); #define BTREE_BULKLOAD 0x00000001 /* Used to full index in sorted order */ #define BTREE_SEEK_EQ 0x00000002 /* EQ seeks only - no range seeks */ -#ifdef SQLITE_ENABLE_CURSOR_HINTS -void sqlite3BtreeCursorHint(BtCursor*, int, ...); -#endif - int sqlite3BtreeCursor( Btree*, /* BTree containing table to open */ int iTable, /* Index of root page */ @@ -217,6 +210,7 @@ int sqlite3BtreeCursor( ); int sqlite3BtreeCursorSize(void); void sqlite3BtreeCursorZero(BtCursor*); +void sqlite3BtreeCursorHint(BtCursor*, int, ...); int sqlite3BtreeCloseCursor(BtCursor*); int sqlite3BtreeMovetoUnpacked( diff --git a/src/vdbe.c b/src/vdbe.c index a18608aa60..c8d2f3adbb 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -3384,10 +3384,12 @@ case OP_OpenWrite: open_cursor_set_hints: assert( OPFLAG_BULKCSR==BTREE_BULKLOAD ); assert( OPFLAG_SEEKEQ==BTREE_SEEK_EQ ); -#ifdef SQLITE_ENABLE_CURSOR_HINTS + testcase( pOp->p5 & OPFLAG_BULKCSR ); +#ifdef SQLITE_ENABLE_CURSOR_HINT + testcase( pOp->p2 & OPFLAG_SEEKEQ ); +#endif sqlite3BtreeCursorHint(pCur->pCursor, BTREE_HINT_FLAGS, (pOp->p5 & (OPFLAG_BULKCSR|OPFLAG_SEEKEQ))); -#endif break; }