mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-22 20:22:44 +03:00
Performance optimizations in the VDBE and especially to the OP_Next and
related opcodes. FossilOrigin-Name: d78c5d89de4b840351b026c9db1952fc24e689d0
This commit is contained in:
18
manifest
18
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Performance\simprovement\sto\sSQL\sfunction\scalls\sin\sthe\sVDBE.
|
C Performance\soptimizations\sin\sthe\sVDBE\sand\sespecially\sto\sthe\sOP_Next\sand\nrelated\sopcodes.
|
||||||
D 2013-08-19T23:18:12.597
|
D 2013-08-20T00:42:11.120
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e
|
F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@@ -163,7 +163,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34
|
|||||||
F src/backup.c 43b348822db3e4cef48b2ae5a445fbeb6c73a165
|
F src/backup.c 43b348822db3e4cef48b2ae5a445fbeb6c73a165
|
||||||
F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb
|
F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb
|
||||||
F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7
|
F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7
|
||||||
F src/btree.c d8cb52cddfe575d91b90d056d91607259f78706b
|
F src/btree.c adea13e65d6c7b969bcd74cea6ae79b2d3c393fa
|
||||||
F src/btree.h bfe0e8c5759b4ec77b0d18390064a6ef3cdffaaf
|
F src/btree.h bfe0e8c5759b4ec77b0d18390064a6ef3cdffaaf
|
||||||
F src/btreeInt.h 51cf220a9b9223354770883e93a859dc377aa27f
|
F src/btreeInt.h 51cf220a9b9223354770883e93a859dc377aa27f
|
||||||
F src/build.c f99a715ff9290996b579d5e1ec8e94239dc9ae5e
|
F src/build.c f99a715ff9290996b579d5e1ec8e94239dc9ae5e
|
||||||
@@ -277,10 +277,10 @@ F src/update.c 7f3fe64d8f3b44c44a1eac293f0f85f87c355b7a
|
|||||||
F src/utf.c 8d819e2e5104a430fc2005f018db14347c95a38f
|
F src/utf.c 8d819e2e5104a430fc2005f018db14347c95a38f
|
||||||
F src/util.c f566b5138099a2df8533b190d0dcc74b7dfbe0c9
|
F src/util.c f566b5138099a2df8533b190d0dcc74b7dfbe0c9
|
||||||
F src/vacuum.c d9c5759f4c5a438bb43c2086f72c5d2edabc36c8
|
F src/vacuum.c d9c5759f4c5a438bb43c2086f72c5d2edabc36c8
|
||||||
F src/vdbe.c 54d28e7fbea2215998f8e12fcb0ddb15fadc5b14
|
F src/vdbe.c 938feb53407dee2234849aad0f103ae9b941595e
|
||||||
F src/vdbe.h 4f554b5627f26710c4c36d919110a3fc611ca5c4
|
F src/vdbe.h 4f554b5627f26710c4c36d919110a3fc611ca5c4
|
||||||
F src/vdbeInt.h 6931139cefc2f01f8612b771a31d96d06b1a6860
|
F src/vdbeInt.h cbe71b8b36d8b3bba5709cc3f436c7e3b47b7b08
|
||||||
F src/vdbeapi.c a183f0daa22374427bd4cf3f18a6261aac141f5a
|
F src/vdbeapi.c 96b24b946cf21894f63d9393e821baa2f0a80979
|
||||||
F src/vdbeaux.c a6ea36a9dc714e1128a0173249a0532ddcab0489
|
F src/vdbeaux.c a6ea36a9dc714e1128a0173249a0532ddcab0489
|
||||||
F src/vdbeblob.c 5dc79627775bd9a9b494dd956e26297946417d69
|
F src/vdbeblob.c 5dc79627775bd9a9b494dd956e26297946417d69
|
||||||
F src/vdbemem.c 833005f1cbbf447289f1973dba2a0c2228c7b8ab
|
F src/vdbemem.c 833005f1cbbf447289f1973dba2a0c2228c7b8ab
|
||||||
@@ -1106,7 +1106,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
|||||||
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
|
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
|
||||||
F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae
|
F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae
|
||||||
F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
|
F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
|
||||||
P 6f99b54aedeb91e46d52f65504d02a9cc61c0062
|
P d2efea1682a7e708000c1f5d36370aaf1199b3be
|
||||||
R a4ebd23f8bd1f91badaa0be999a387b9
|
R 08cd0ad5f78761d7e8cb97606228a179
|
||||||
U drh
|
U drh
|
||||||
Z 07c571cc9e32147d1ee20914dbc33fe8
|
Z 1caed0652391fde507351b876419455b
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
d2efea1682a7e708000c1f5d36370aaf1199b3be
|
d78c5d89de4b840351b026c9db1952fc24e689d0
|
||||||
12
src/btree.c
12
src/btree.c
@@ -4804,6 +4804,7 @@ int sqlite3BtreeNext(BtCursor *pCur, int *pRes){
|
|||||||
if( pCur->eState!=CURSOR_VALID ){
|
if( pCur->eState!=CURSOR_VALID ){
|
||||||
rc = restoreCursorPosition(pCur);
|
rc = restoreCursorPosition(pCur);
|
||||||
if( rc!=SQLITE_OK ){
|
if( rc!=SQLITE_OK ){
|
||||||
|
*pRes = 0;
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
if( CURSOR_INVALID==pCur->eState ){
|
if( CURSOR_INVALID==pCur->eState ){
|
||||||
@@ -4838,7 +4839,10 @@ int sqlite3BtreeNext(BtCursor *pCur, int *pRes){
|
|||||||
if( idx>=pPage->nCell ){
|
if( idx>=pPage->nCell ){
|
||||||
if( !pPage->leaf ){
|
if( !pPage->leaf ){
|
||||||
rc = moveToChild(pCur, get4byte(&pPage->aData[pPage->hdrOffset+8]));
|
rc = moveToChild(pCur, get4byte(&pPage->aData[pPage->hdrOffset+8]));
|
||||||
if( rc ) return rc;
|
if( rc ){
|
||||||
|
*pRes = 0;
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
rc = moveToLeftmost(pCur);
|
rc = moveToLeftmost(pCur);
|
||||||
*pRes = 0;
|
*pRes = 0;
|
||||||
return rc;
|
return rc;
|
||||||
@@ -4886,7 +4890,10 @@ int sqlite3BtreePrevious(BtCursor *pCur, int *pRes){
|
|||||||
if( pCur->eState!=CURSOR_VALID ){
|
if( pCur->eState!=CURSOR_VALID ){
|
||||||
if( ALWAYS(pCur->eState>=CURSOR_REQUIRESEEK) ){
|
if( ALWAYS(pCur->eState>=CURSOR_REQUIRESEEK) ){
|
||||||
rc = btreeRestoreCursorPosition(pCur);
|
rc = btreeRestoreCursorPosition(pCur);
|
||||||
if( rc!=SQLITE_OK ) return rc;
|
if( rc!=SQLITE_OK ){
|
||||||
|
*pRes = 0;
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if( CURSOR_INVALID==pCur->eState ){
|
if( CURSOR_INVALID==pCur->eState ){
|
||||||
*pRes = 1;
|
*pRes = 1;
|
||||||
@@ -4910,6 +4917,7 @@ int sqlite3BtreePrevious(BtCursor *pCur, int *pRes){
|
|||||||
int idx = pCur->aiIdx[pCur->iPage];
|
int idx = pCur->aiIdx[pCur->iPage];
|
||||||
rc = moveToChild(pCur, get4byte(findCell(pPage, idx)));
|
rc = moveToChild(pCur, get4byte(findCell(pPage, idx)));
|
||||||
if( rc ){
|
if( rc ){
|
||||||
|
*pRes = 0;
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
rc = moveToRightmost(pCur);
|
rc = moveToRightmost(pCur);
|
||||||
|
|||||||
18
src/vdbe.c
18
src/vdbe.c
@@ -588,7 +588,7 @@ int sqlite3VdbeExec(
|
|||||||
#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
|
#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
|
||||||
if( db->xProgress ){
|
if( db->xProgress ){
|
||||||
assert( 0 < db->nProgressOps );
|
assert( 0 < db->nProgressOps );
|
||||||
nProgressLimit = (unsigned)p->aCounter[SQLITE_STMTSTATUS_VM_STEP-1];
|
nProgressLimit = (unsigned)p->aCounter[SQLITE_STMTSTATUS_VM_STEP];
|
||||||
if( nProgressLimit==0 ){
|
if( nProgressLimit==0 ){
|
||||||
nProgressLimit = db->nProgressOps;
|
nProgressLimit = db->nProgressOps;
|
||||||
}else{
|
}else{
|
||||||
@@ -1848,12 +1848,12 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */
|
|||||||
** then the result is always NULL.
|
** then the result is always NULL.
|
||||||
** The jump is taken if the SQLITE_JUMPIFNULL bit is set.
|
** The jump is taken if the SQLITE_JUMPIFNULL bit is set.
|
||||||
*/
|
*/
|
||||||
if( pOp->p5 & SQLITE_STOREP2 ){
|
if( pOp->p5 & SQLITE_JUMPIFNULL ){
|
||||||
|
pc = pOp->p2-1;
|
||||||
|
}else if( pOp->p5 & SQLITE_STOREP2 ){
|
||||||
pOut = &aMem[pOp->p2];
|
pOut = &aMem[pOp->p2];
|
||||||
MemSetTypeFlag(pOut, MEM_Null);
|
MemSetTypeFlag(pOut, MEM_Null);
|
||||||
REGISTER_TRACE(pOp->p2, pOut);
|
REGISTER_TRACE(pOp->p2, pOut);
|
||||||
}else if( pOp->p5 & SQLITE_JUMPIFNULL ){
|
|
||||||
pc = pOp->p2-1;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -4438,7 +4438,7 @@ case OP_Sort: { /* jump */
|
|||||||
sqlite3_sort_count++;
|
sqlite3_sort_count++;
|
||||||
sqlite3_search_count--;
|
sqlite3_search_count--;
|
||||||
#endif
|
#endif
|
||||||
p->aCounter[SQLITE_STMTSTATUS_SORT-1]++;
|
p->aCounter[SQLITE_STMTSTATUS_SORT]++;
|
||||||
/* Fall through into OP_Rewind */
|
/* Fall through into OP_Rewind */
|
||||||
}
|
}
|
||||||
/* Opcode: Rewind P1 P2 * * *
|
/* Opcode: Rewind P1 P2 * * *
|
||||||
@@ -4517,7 +4517,7 @@ case OP_Next: { /* jump */
|
|||||||
int res;
|
int res;
|
||||||
|
|
||||||
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
|
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
|
||||||
assert( pOp->p5<=ArraySize(p->aCounter) );
|
assert( pOp->p5<ArraySize(p->aCounter) );
|
||||||
pC = p->apCsr[pOp->p1];
|
pC = p->apCsr[pOp->p1];
|
||||||
if( pC==0 ){
|
if( pC==0 ){
|
||||||
break; /* See ticket #2273 */
|
break; /* See ticket #2273 */
|
||||||
@@ -4527,7 +4527,7 @@ case OP_Next: { /* jump */
|
|||||||
assert( pOp->opcode==OP_SorterNext );
|
assert( pOp->opcode==OP_SorterNext );
|
||||||
rc = sqlite3VdbeSorterNext(db, pC, &res);
|
rc = sqlite3VdbeSorterNext(db, pC, &res);
|
||||||
}else{
|
}else{
|
||||||
res = 1;
|
/* res = 1; // Always initialized by the xAdvance() call */
|
||||||
assert( pC->deferredMoveto==0 );
|
assert( pC->deferredMoveto==0 );
|
||||||
assert( pC->pCursor );
|
assert( pC->pCursor );
|
||||||
assert( pOp->opcode!=OP_Next || pOp->p4.xAdvance==sqlite3BtreeNext );
|
assert( pOp->opcode!=OP_Next || pOp->p4.xAdvance==sqlite3BtreeNext );
|
||||||
@@ -4538,7 +4538,7 @@ case OP_Next: { /* jump */
|
|||||||
pC->cacheStatus = CACHE_STALE;
|
pC->cacheStatus = CACHE_STALE;
|
||||||
if( res==0 ){
|
if( res==0 ){
|
||||||
pc = pOp->p2 - 1;
|
pc = pOp->p2 - 1;
|
||||||
if( pOp->p5 ) p->aCounter[pOp->p5-1]++;
|
p->aCounter[pOp->p5]++;
|
||||||
#ifdef SQLITE_TEST
|
#ifdef SQLITE_TEST
|
||||||
sqlite3_search_count++;
|
sqlite3_search_count++;
|
||||||
#endif
|
#endif
|
||||||
@@ -6241,7 +6241,7 @@ vdbe_error_halt:
|
|||||||
vdbe_return:
|
vdbe_return:
|
||||||
db->lastRowid = lastRowid;
|
db->lastRowid = lastRowid;
|
||||||
testcase( nVmStep>0 );
|
testcase( nVmStep>0 );
|
||||||
p->aCounter[SQLITE_STMTSTATUS_VM_STEP-1] += (int)nVmStep;
|
p->aCounter[SQLITE_STMTSTATUS_VM_STEP] += (int)nVmStep;
|
||||||
sqlite3VdbeLeave(p);
|
sqlite3VdbeLeave(p);
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
|
|||||||
@@ -346,7 +346,7 @@ struct Vdbe {
|
|||||||
yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */
|
yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */
|
||||||
yDbMask lockMask; /* Subset of btreeMask that requires a lock */
|
yDbMask lockMask; /* Subset of btreeMask that requires a lock */
|
||||||
int iStatement; /* Statement number (or 0 if has not opened stmt) */
|
int iStatement; /* Statement number (or 0 if has not opened stmt) */
|
||||||
int aCounter[4]; /* Counters used by sqlite3_stmt_status() */
|
u32 aCounter[5]; /* Counters used by sqlite3_stmt_status() */
|
||||||
#ifndef SQLITE_OMIT_TRACE
|
#ifndef SQLITE_OMIT_TRACE
|
||||||
i64 startTime; /* Time when query started - used for profiling */
|
i64 startTime; /* Time when query started - used for profiling */
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1298,7 +1298,7 @@ sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt){
|
|||||||
*/
|
*/
|
||||||
int sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int resetFlag){
|
int sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int resetFlag){
|
||||||
Vdbe *pVdbe = (Vdbe*)pStmt;
|
Vdbe *pVdbe = (Vdbe*)pStmt;
|
||||||
int v = pVdbe->aCounter[op-1];
|
u32 v = pVdbe->aCounter[op];
|
||||||
if( resetFlag ) pVdbe->aCounter[op-1] = 0;
|
if( resetFlag ) pVdbe->aCounter[op] = 0;
|
||||||
return v;
|
return (int)v;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user