diff options
author | drh <drh@noemail.net> | 2017-01-21 16:54:19 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2017-01-21 16:54:19 +0000 |
commit | 451e76d5b594d48d3450057ac542c7635b74b021 (patch) | |
tree | 6ef4cd97375a3489005cd7820aefa3ec5f09804c /src | |
parent | 3b2936fada3ed75241188276c19e4c65a57ab665 (diff) | |
download | sqlite-451e76d5b594d48d3450057ac542c7635b74b021.tar.gz sqlite-451e76d5b594d48d3450057ac542c7635b74b021.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/btree.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/btree.c b/src/btree.c index fb0565591..8b095b57b 100644 --- a/src/btree.c +++ b/src/btree.c @@ -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; + } + } } } |