]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Do not read the last page of a overflow chain when deleting that chain.
authordrh <drh@noemail.net>
Tue, 6 Mar 2007 11:42:19 +0000 (11:42 +0000)
committerdrh <drh@noemail.net>
Tue, 6 Mar 2007 11:42:19 +0000 (11:42 +0000)
Just add the page to the freelist.  This reduces I/O. (CVS 3672)

FossilOrigin-Name: 6db945f7a7587c8c7adada92f94ac7936b901cf1

manifest
manifest.uuid
src/btree.c

index 4d199ddcd49d3bd791516ce22997bd3660ee5ab5..5eaf6690f5b366c0a5384bb175cf11e21c6db1d9 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Changes\sto\sthe\sbtree\sand\spager\sthat\sreduce\sthe\samount\sof\sI/O\swhen\sdealing\nwith\sthe\sfreelist.\s\s(1)\sAvoid\sjournaling\spages\sof\sa\stable\sthat\sis\sbeing\ndeleted.\s\s(2)\sDo\snot\sread\sthe\soriginal\scontent\sof\spages\sbeing\spulled\soff\nof\sthe\sfreelist.\s(CVS\s3671)
-D 2007-03-04T13:15:28
+C Do\snot\sread\sthe\slast\spage\sof\sa\soverflow\schain\swhen\sdeleting\sthat\schain.\r\nJust\sadd\sthe\spage\sto\sthe\sfreelist.\s\sThis\sreduces\sI/O.\s(CVS\s3672)
+D 2007-03-06T11:42:19
 F Makefile.in 1fe3d0b46e40fd684e1e61f8e8056cefed16de9f
 F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -57,7 +57,7 @@ F src/alter.c 2c79ec40f65e33deaf90ca493422c74586e481a3
 F src/analyze.c 7d2b7ab9a9c2fd6e55700f69064dfdd3e36d7a8a
 F src/attach.c b11eb4d5d3fb99a10a626956bccc7215f6b68b16
 F src/auth.c 902f4722661c796b97f007d9606bd7529c02597f
-F src/btree.c 866536a3c667de942747ee3fd3914b31bb273fee
+F src/btree.c d42d2b634a5099cd6cb92d4482fba980ddc6635f
 F src/btree.h 066444ee25bd6e6accb997bfd2cf5ace14dbcd00
 F src/build.c 6bd68dc730b01c1727738f8e4b5c730eb0ddb421
 F src/callback.c 31d22b4919c7645cbcbb1591ce2453e8c677c558
@@ -435,7 +435,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P 52885ed8b76a06588acf202a38b4feabfca1cfd1
-R 35bc70c2ff87b67600b039941003bc67
+P 2ba5be311945a4c15b6dce7c01efefb513b9a973
+R b6b1462461ede272fb76bf4d7e144940
 U drh
-Z a8523f47620c390e8f111fe930472ba8
+Z ecb4e965eec3f8ba87257a871ce271b7
index 975c7d4dcb44f6656ebaca860f3f1403cfb75470..711bdeb71fa29fa7cdfc1206a12199f8779927d8 100644 (file)
@@ -1 +1 @@
-2ba5be311945a4c15b6dce7c01efefb513b9a973
\ No newline at end of file
+6db945f7a7587c8c7adada92f94ac7936b901cf1
\ No newline at end of file
index e3ec85a48572400103e26e5944429101e9ed8847..368b3809548ba64d34e33dbe44a5149de6dca6e2 100644 (file)
@@ -9,7 +9,7 @@
 **    May you share freely, never taking more than you give.
 **
 *************************************************************************
-** $Id: btree.c,v 1.336 2007/03/04 13:15:28 drh Exp $
+** $Id: btree.c,v 1.337 2007/03/06 11:42:19 drh Exp $
 **
 ** This file implements a external (disk-based) database using BTrees.
 ** For a detailed discussion of BTrees, refer to
@@ -1394,6 +1394,9 @@ static int getPage(BtShared *pBt, Pgno pgno, MemPage **ppPage, int clrFlag){
   pPage->pgno = pgno;
   pPage->hdrOffset = pPage->pgno==1 ? 100 : 0;
   *ppPage = pPage;
+  if( clrFlag ){
+    sqlite3pager_dont_rollback(aData);
+  }
   return SQLITE_OK;
 }
 
@@ -3736,7 +3739,6 @@ static int allocatePage(
           put4byte(&aData[4], k-1);
           rc = getPage(pBt, *pPgno, ppPage, 1);
           if( rc==SQLITE_OK ){
-            sqlite3pager_dont_rollback((*ppPage)->aData);
             rc = sqlite3pager_write((*ppPage)->aData);
             if( rc!=SQLITE_OK ){
               releasePage(*ppPage);
@@ -3872,24 +3874,32 @@ static int clearCell(MemPage *pPage, unsigned char *pCell){
   CellInfo info;
   Pgno ovflPgno;
   int rc;
+  int nOvfl;
+  int ovflPageSize;
+  int nPayload;
 
   parseCellPtr(pPage, pCell, &info);
   if( info.iOverflow==0 ){
     return SQLITE_OK;  /* No overflow pages. Return without doing anything */
   }
   ovflPgno = get4byte(&pCell[info.iOverflow]);
+  nPayload = pPage->intKey ? info.nData : info.nKey;
+  ovflPageSize = pBt->usableSize - 4;
+  nOvfl = (nPayload - info.nLocal + ovflPageSize - 1)/ovflPageSize;
   while( ovflPgno!=0 ){
     MemPage *pOvfl;
+    nOvfl--;
     if( ovflPgno>sqlite3pager_pagecount(pBt->pPager) ){
       return SQLITE_CORRUPT_BKPT;
     }
-    rc = getPage(pBt, ovflPgno, &pOvfl, 0);
+    rc = getPage(pBt, ovflPgno, &pOvfl, nOvfl==0);
     if( rc ) return rc;
     ovflPgno = get4byte(pOvfl->aData);
     rc = freePage(pOvfl);
     sqlite3pager_unref(pOvfl->aData);
     if( rc ) return rc;
   }
+  assert( nOvfl==0 );
   return SQLITE_OK;
 }