SQLite

Check-in [a74675607f]
Login

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

Overview
Comment:Arrange for sqlite3BtreeMovetoUnpacked() to always leave the cursor cell parse cache invalidated. This fixes issues with previous check-ins on this branch and also runs faster.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | btree-optimization
Files: files | file ages | folders
SHA1: a74675607fe041e37a58a3ec287131de0e5090c3
User & Date: drh 2013-11-25 16:23:52.282
Context
2013-11-25
16:52
Optimize the skipping of the payload size field when doing a binary search for a rowid. (check-in: 55e5bfa231 user: drh tags: btree-optimization)
16:23
Arrange for sqlite3BtreeMovetoUnpacked() to always leave the cursor cell parse cache invalidated. This fixes issues with previous check-ins on this branch and also runs faster. (check-in: a74675607f user: drh tags: btree-optimization)
15:01
More optimizations to sqlite3BtreeMovetoUnpacked(). But there are failures in TH3. Committing this intermediate state to facilitate bisecting. (check-in: f80497be44 user: drh tags: btree-optimization)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/btree.c.
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
  u32 nLocal;

  assert( pCur!=0 && pCur->iPage>=0 && pCur->apPage[pCur->iPage]);
  assert( pCur->eState==CURSOR_VALID );
  assert( cursorHoldsMutex(pCur) );
  pPage = pCur->apPage[pCur->iPage];
  assert( pCur->aiIdx[pCur->iPage]<pPage->nCell );
  if( NEVER(pCur->info.nSize==0) ){
    btreeParseCell(pCur->apPage[pCur->iPage], pCur->aiIdx[pCur->iPage],
                   &pCur->info);
  }
  aPayload = pCur->info.pCell;
  aPayload += pCur->info.nHeader;
  if( pPage->intKey ){
    nKey = 0;







|







4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
  u32 nLocal;

  assert( pCur!=0 && pCur->iPage>=0 && pCur->apPage[pCur->iPage]);
  assert( pCur->eState==CURSOR_VALID );
  assert( cursorHoldsMutex(pCur) );
  pPage = pCur->apPage[pCur->iPage];
  assert( pCur->aiIdx[pCur->iPage]<pPage->nCell );
  if( pCur->info.nSize==0 ){
    btreeParseCell(pCur->apPage[pCur->iPage], pCur->aiIdx[pCur->iPage],
                   &pCur->info);
  }
  aPayload = pCur->info.pCell;
  aPayload += pCur->info.nHeader;
  if( pPage->intKey ){
    nKey = 0;
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
    ** a moveToChild() or moveToRoot() call would have detected corruption.  */
    assert( pPage->nCell>0 );
    assert( pPage->intKey==(pIdxKey==0) );
    lwr = 0;
    upr = pPage->nCell-1;
    idx = biasRight ? upr : upr/2;
    pCur->aiIdx[pCur->iPage] = (u16)idx;
    pCur->info.nSize = 0;
    if( pPage->intKey ){
      for(;;){
        i64 nCellKey;
        pCell = findCell(pPage, idx) + pPage->childPtrSize;
        if( pPage->hasData ){
          u32 dummy;
          pCell += getVarint32(pCell, dummy);







|







4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
    ** a moveToChild() or moveToRoot() call would have detected corruption.  */
    assert( pPage->nCell>0 );
    assert( pPage->intKey==(pIdxKey==0) );
    lwr = 0;
    upr = pPage->nCell-1;
    idx = biasRight ? upr : upr/2;
    pCur->aiIdx[pCur->iPage] = (u16)idx;
//    pCur->info.nSize = 0;
    if( pPage->intKey ){
      for(;;){
        i64 nCellKey;
        pCell = findCell(pPage, idx) + pPage->childPtrSize;
        if( pPage->hasData ){
          u32 dummy;
          pCell += getVarint32(pCell, dummy);
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789


4790
4791
4792
4793
4794
4795
4796
      goto moveto_finish;
    }else if( lwr>=pPage->nCell ){
      chldPg = get4byte(&pPage->aData[pPage->hdrOffset+8]);
    }else{
      chldPg = get4byte(findCell(pPage, lwr));
    }
    pCur->aiIdx[pCur->iPage] = (u16)lwr;
    pCur->info.nSize = 0;
    pCur->validNKey = 0;
    rc = moveToChild(pCur, chldPg);
    if( rc ) break;
  }
moveto_finish:


  return rc;
}


/*
** Return TRUE if the cursor is not pointing at an entry of the table.
**







<
<




>
>







4777
4778
4779
4780
4781
4782
4783


4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
      goto moveto_finish;
    }else if( lwr>=pPage->nCell ){
      chldPg = get4byte(&pPage->aData[pPage->hdrOffset+8]);
    }else{
      chldPg = get4byte(findCell(pPage, lwr));
    }
    pCur->aiIdx[pCur->iPage] = (u16)lwr;


    rc = moveToChild(pCur, chldPg);
    if( rc ) break;
  }
moveto_finish:
  pCur->info.nSize = 0;
  pCur->validNKey = 0;
  return rc;
}


/*
** Return TRUE if the cursor is not pointing at an entry of the table.
**