SQLite

Check-in [8e5cfb2039]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: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.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | btree-moveto-neighbor
Files: files | file ages | folders
SHA1: 8e5cfb2039126da7689c4b1c88760f10e1234eaf
User & Date: drh 2017-01-21 16:54:19.338
Context
2017-01-21
21:47
A better implementation of the moveto-neighbor optimization that checks for nearby rows on adjacent pages. (Closed-Leaf check-in: 2c4ecb85a4 user: drh tags: btree-moveto-neighbor)
16:54
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. (check-in: 8e5cfb2039 user: drh tags: btree-moveto-neighbor)
16:27
Change sqlite3_blob_reopen() to call sqlite3VdbeExec() directly rather than going through sqlite3_step(). Performance enhancement. (check-in: 347df3c1fd user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/btree.c.
5087
5088
5089
5090
5091
5092
5093

5094
5095
5096











5097
5098
5099
5100
5101
5102
5103
  if( pIdxKey==0
   && pCur->eState==CURSOR_VALID && (pCur->curFlags & BTCF_ValidNKey)!=0
  ){
    if( pCur->info.nKey==intKey ){
      *pRes = 0;
      return SQLITE_OK;
    }

    if( (pCur->curFlags & BTCF_AtLast)!=0 && pCur->info.nKey<intKey ){
      *pRes = -1;
      return SQLITE_OK;











    }
  }

  if( pIdxKey ){
    xRecordCompare = sqlite3VdbeFindCompare(pIdxKey);
    pIdxKey->errCode = 0;
    assert( pIdxKey->default_rc==1 







>
|
|
|
>
>
>
>
>
>
>
>
>
>
>







5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
  if( pIdxKey==0
   && pCur->eState==CURSOR_VALID && (pCur->curFlags & BTCF_ValidNKey)!=0
  ){
    if( pCur->info.nKey==intKey ){
      *pRes = 0;
      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;
        }
      }
    }
  }

  if( pIdxKey ){
    xRecordCompare = sqlite3VdbeFindCompare(pIdxKey);
    pIdxKey->errCode = 0;
    assert( pIdxKey->default_rc==1