mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Performance enhancement: avoid calling reparentChildPages() from balance_nonroot(). (CVS 5743)
FossilOrigin-Name: 28fd0a50ca8529892f5b1ababd38d494889eed6d
This commit is contained in:
12
manifest
12
manifest
@@ -1,5 +1,5 @@
|
||||
C On\swindows,\savoid\srunning\sthose\stests\sin\sexclusive.test\sthat\srequire\sthe\sjournal\sfile\sto\sbe\sexternally\saccessed\swhile\sSQLite\sis\sholding\sit\sopen.\sThis\sdoesn't\swork\son\swindows.\s(CVS\s5742)
|
||||
D 2008-09-24T14:03:43
|
||||
C Performance\senhancement:\savoid\scalling\sreparentChildPages()\sfrom\sbalance_nonroot().\s(CVS\s5743)
|
||||
D 2008-09-26T17:31:55
|
||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||
F Makefile.in e4ab842f9a64ef61d57093539a8aab76b12810db
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
@@ -99,7 +99,7 @@ F src/attach.c db3f4a60538733c1e4dcb9d0217a6e0d6ccd615b
|
||||
F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627
|
||||
F src/bitvec.c 95c86bd18d8fedf0533f5af196192546e10a7e7d
|
||||
F src/btmutex.c 709cad2cdca0afd013f0f612363810e53f59ec53
|
||||
F src/btree.c 4d642d23fc4507089f702eb24b506be2ce7e0efd
|
||||
F src/btree.c 850d7ede7fe58f8bfad78131278ceff83817abf5
|
||||
F src/btree.h 6371c5e599fab391a150c96afbc10062b276d107
|
||||
F src/btreeInt.h e36f77e6621d671beb19ae581af1eba116cdfdc4
|
||||
F src/build.c 160c71acca8f643f436ed6c1ee2f684c88df4dfe
|
||||
@@ -637,7 +637,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
|
||||
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
P 0acca5842f83943228d4225b60dc7e8a42bae577
|
||||
R 9eb08ed19a8499580c1afb4ad41aa2b7
|
||||
P 5debf12fa46520946ac5da44c03448fffbc9940c
|
||||
R ad8baa95733fbb9a312a15654e608ce1
|
||||
U danielk1977
|
||||
Z 7daec82c5a8b96a531bdb9c3bccd5b3b
|
||||
Z 410e2e4a76b6dc0451fd1f6a24aebc75
|
||||
|
@@ -1 +1 @@
|
||||
5debf12fa46520946ac5da44c03448fffbc9940c
|
||||
28fd0a50ca8529892f5b1ababd38d494889eed6d
|
50
src/btree.c
50
src/btree.c
@@ -9,7 +9,7 @@
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** $Id: btree.c,v 1.516 2008/09/19 16:39:38 danielk1977 Exp $
|
||||
** $Id: btree.c,v 1.517 2008/09/26 17:31:55 danielk1977 Exp $
|
||||
**
|
||||
** This file implements a external (disk-based) database using BTrees.
|
||||
** See the header comment on "btreeInt.h" for additional information.
|
||||
@@ -5586,14 +5586,46 @@ static int balance_nonroot(MemPage *pPage){
|
||||
}
|
||||
|
||||
/*
|
||||
** Reparent children of all cells.
|
||||
** At this point we used to call reparentChildPages() to make sure that
|
||||
** the MemPage.pParent and MemPage.idxParent variables are correct for
|
||||
** all children of the pages modified by this balance operation. Even
|
||||
** if this is an auto-vacuum database there is no need to update the
|
||||
** pointer-map entries for child pages - that has already been done
|
||||
** by the block above.
|
||||
**
|
||||
** However, this is no longer necessary because the MemPage.pParent and
|
||||
** MemPage.idxParent variables are only assumed to be valid when there
|
||||
** are one or more references to the page (when isInit==PAGE_ISINIT_FULL).
|
||||
** At this point we can account for all references to the pages
|
||||
** manipulated by this function and deduce that it is not necessary to
|
||||
** update these two variables because:
|
||||
**
|
||||
** a) it must have been called, directly or indirectly, from BtreeInsert()
|
||||
** or BtreeDelete(). Both these functions call saveAllCursors(), so
|
||||
** we can be sure that there exactly one write-cursor (and no
|
||||
** read-cursors) open on the b-tree being manipulated. No other
|
||||
** cursor may be holding references to any pages in the b-tree.
|
||||
**
|
||||
** b) After this function returns, the one open write-cursor will be
|
||||
** moved to point at the root of the table using moveToRoot(). The
|
||||
** code that does this (see BtreeInsert() and BtreeDelete()) ensures
|
||||
** that the MemPage.pParent variables are not used to find the root
|
||||
** page of the b-tree, it is located using BtCursor.pgnoRoot.
|
||||
**
|
||||
** c) the other page references are those held by this function, on
|
||||
** the pages in apNew[] and apOld[]. They are about to be released.
|
||||
**
|
||||
** Therefore, no need to call reparentChildPages(). This can be a
|
||||
** significant performance boost.
|
||||
*/
|
||||
#if 0
|
||||
for(i=0; i<nNew; i++){
|
||||
rc = reparentChildPages(apNew[i], 0);
|
||||
if( rc!=SQLITE_OK ) goto balance_cleanup;
|
||||
}
|
||||
rc = reparentChildPages(pParent, 0);
|
||||
if( rc!=SQLITE_OK ) goto balance_cleanup;
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Balance the parent page. Note that the current page (pPage) might
|
||||
@@ -5973,6 +6005,13 @@ int sqlite3BtreeInsert(
|
||||
if( rc!=SQLITE_OK ) goto end_insert;
|
||||
rc = balance(pPage, 1);
|
||||
if( rc==SQLITE_OK ){
|
||||
/* balance() may have messed up the chain of MemPage.pParent pointers.
|
||||
** To prevent moveToRoot() from trying to use them to locate the root
|
||||
** page of this table, release the reference to the current page before
|
||||
** calling it.
|
||||
*/
|
||||
releasePage(pCur->pPage);
|
||||
pCur->pPage = 0;
|
||||
moveToRoot(pCur);
|
||||
}
|
||||
end_insert:
|
||||
@@ -6089,6 +6128,13 @@ int sqlite3BtreeDelete(BtCursor *pCur){
|
||||
rc = balance(pPage, 0);
|
||||
}
|
||||
if( rc==SQLITE_OK ){
|
||||
/* balance() may have messed up the chain of MemPage.pParent pointers.
|
||||
** To prevent moveToRoot() from trying to use them to locate the root
|
||||
** page of this table, release the reference to the current page before
|
||||
** calling it.
|
||||
*/
|
||||
releasePage(pCur->pPage);
|
||||
pCur->pPage = 0;
|
||||
moveToRoot(pCur);
|
||||
}
|
||||
return rc;
|
||||
|
Reference in New Issue
Block a user