1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

B-tree optimization: When seeking on a rowid table that has already been

positioned, check to see if the new row happens to be the next row on the
same leaf page.  That is a reasonably common case, and if it is true it
avoids a full binary search.

FossilOrigin-Name: 8e5cfb2039126da7689c4b1c88760f10e1234eaf
This commit is contained in:
drh
2017-01-21 16:54:19 +00:00
parent 3b2936fada
commit 451e76d5b5
3 changed files with 22 additions and 10 deletions

View File

@@ -5091,9 +5091,21 @@ int sqlite3BtreeMovetoUnpacked(
*pRes = 0;
return SQLITE_OK;
}
if( (pCur->curFlags & BTCF_AtLast)!=0 && pCur->info.nKey<intKey ){
*pRes = -1;
return SQLITE_OK;
if( pCur->info.nKey<intKey ){
if( (pCur->curFlags & BTCF_AtLast)!=0 ){
*pRes = -1;
return SQLITE_OK;
}
if( pCur->aiIdx[pCur->iPage]+1<pCur->apPage[pCur->iPage]->nCell ){
pCur->aiIdx[pCur->iPage]++;
pCur->info.nSize = 0;
pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl);
getCellInfo(pCur);
if( pCur->info.nKey==intKey ){
*pRes = 0;
return SQLITE_OK;
}
}
}
}