/ Check-in [6db945f7]
Login

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

Overview
Comment:Do not read the last page of a overflow chain when deleting that chain. Just add the page to the freelist. This reduces I/O. (CVS 3672)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6db945f7a7587c8c7adada92f94ac7936b901cf1
User & Date: drh 2007-03-06 11:42:19
Context
2007-03-06
13:46
Use heap instead of stack for large buffers in the pager. Fix for #2262. (CVS 3673) check-in: dfe1dffa user: danielk1977 tags: trunk
11:42
Do not read the last page of a overflow chain when deleting that chain. Just add the page to the freelist. This reduces I/O. (CVS 3672) check-in: 6db945f7 user: drh tags: trunk
2007-03-04
13:15
Changes to the btree and pager that reduce the amount of I/O when dealing with the freelist. (1) Avoid journaling pages of a table that is being deleted. (2) Do not read the original content of pages being pulled off of the freelist. (CVS 3671) check-in: 2ba5be31 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

     5      5   ** a legal notice, here is a blessing:
     6      6   **
     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12         -** $Id: btree.c,v 1.336 2007/03/04 13:15:28 drh Exp $
           12  +** $Id: btree.c,v 1.337 2007/03/06 11:42:19 drh Exp $
    13     13   **
    14     14   ** This file implements a external (disk-based) database using BTrees.
    15     15   ** For a detailed discussion of BTrees, refer to
    16     16   **
    17     17   **     Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3:
    18     18   **     "Sorting And Searching", pages 473-480. Addison-Wesley
    19     19   **     Publishing Company, Reading, Massachusetts.
................................................................................
  1390   1390     if( rc ) return rc;
  1391   1391     pPage = (MemPage*)&aData[pBt->pageSize];
  1392   1392     pPage->aData = aData;
  1393   1393     pPage->pBt = pBt;
  1394   1394     pPage->pgno = pgno;
  1395   1395     pPage->hdrOffset = pPage->pgno==1 ? 100 : 0;
  1396   1396     *ppPage = pPage;
         1397  +  if( clrFlag ){
         1398  +    sqlite3pager_dont_rollback(aData);
         1399  +  }
  1397   1400     return SQLITE_OK;
  1398   1401   }
  1399   1402   
  1400   1403   /*
  1401   1404   ** Get a page from the pager and initialize it.  This routine
  1402   1405   ** is just a convenience wrapper around separate calls to
  1403   1406   ** getPage() and initPage().
................................................................................
  3732   3735                    *pPgno, closest+1, k, pTrunk->pgno, n-1));
  3733   3736             if( closest<k-1 ){
  3734   3737               memcpy(&aData[8+closest*4], &aData[4+k*4], 4);
  3735   3738             }
  3736   3739             put4byte(&aData[4], k-1);
  3737   3740             rc = getPage(pBt, *pPgno, ppPage, 1);
  3738   3741             if( rc==SQLITE_OK ){
  3739         -            sqlite3pager_dont_rollback((*ppPage)->aData);
  3740   3742               rc = sqlite3pager_write((*ppPage)->aData);
  3741   3743               if( rc!=SQLITE_OK ){
  3742   3744                 releasePage(*ppPage);
  3743   3745               }
  3744   3746             }
  3745   3747             searchList = 0;
  3746   3748           }
................................................................................
  3868   3870   ** Free any overflow pages associated with the given Cell.
  3869   3871   */
  3870   3872   static int clearCell(MemPage *pPage, unsigned char *pCell){
  3871   3873     BtShared *pBt = pPage->pBt;
  3872   3874     CellInfo info;
  3873   3875     Pgno ovflPgno;
  3874   3876     int rc;
         3877  +  int nOvfl;
         3878  +  int ovflPageSize;
         3879  +  int nPayload;
  3875   3880   
  3876   3881     parseCellPtr(pPage, pCell, &info);
  3877   3882     if( info.iOverflow==0 ){
  3878   3883       return SQLITE_OK;  /* No overflow pages. Return without doing anything */
  3879   3884     }
  3880   3885     ovflPgno = get4byte(&pCell[info.iOverflow]);
         3886  +  nPayload = pPage->intKey ? info.nData : info.nKey;
         3887  +  ovflPageSize = pBt->usableSize - 4;
         3888  +  nOvfl = (nPayload - info.nLocal + ovflPageSize - 1)/ovflPageSize;
  3881   3889     while( ovflPgno!=0 ){
  3882   3890       MemPage *pOvfl;
         3891  +    nOvfl--;
  3883   3892       if( ovflPgno>sqlite3pager_pagecount(pBt->pPager) ){
  3884   3893         return SQLITE_CORRUPT_BKPT;
  3885   3894       }
  3886         -    rc = getPage(pBt, ovflPgno, &pOvfl, 0);
         3895  +    rc = getPage(pBt, ovflPgno, &pOvfl, nOvfl==0);
  3887   3896       if( rc ) return rc;
  3888   3897       ovflPgno = get4byte(pOvfl->aData);
  3889   3898       rc = freePage(pOvfl);
  3890   3899       sqlite3pager_unref(pOvfl->aData);
  3891   3900       if( rc ) return rc;
  3892   3901     }
         3902  +  assert( nOvfl==0 );
  3893   3903     return SQLITE_OK;
  3894   3904   }
  3895   3905   
  3896   3906   /*
  3897   3907   ** Create the byte sequence used to represent a cell on page pPage
  3898   3908   ** and write that byte sequence into pCell[].  Overflow pages are
  3899   3909   ** allocated and filled in as necessary.  The calling procedure