In function moveToRoot(), use the MemPage.pParent pointers to find the root page if they are valid. This is slightly faster than requesting a new reference to the root page from the pager layer. (CVS 5725)
FossilOrigin-Name: 0c8b74e668b7462c5439c04993d1d7cd74210075
This commit is contained in:
parent
ea89730823
commit
d9f6c53232
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C In\ssqlite3BtreeGetMeta(),\sif\sBtShared.pPage1\sis\savailable\suse\sit\sinstead\sof\srequesting\sa\snew\sreference\sfrom\sthe\spager\slayer.\s(CVS\s5724)
|
||||
D 2008-09-19T15:10:58
|
||||
C In\sfunction\smoveToRoot(),\suse\sthe\sMemPage.pParent\spointers\sto\sfind\sthe\sroot\spage\sif\sthey\sare\svalid.\sThis\sis\sslightly\sfaster\sthan\srequesting\sa\snew\sreference\sto\sthe\sroot\spage\sfrom\sthe\spager\slayer.\s(CVS\s5725)
|
||||
D 2008-09-19T16:39:38
|
||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||
F Makefile.in d15a7ebfe5e057a72a49805ffb302dbb601c8329
|
||||
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 cfe8dbbaa75f587653f33121c3e82999c65069ae
|
||||
F src/btree.c 4d642d23fc4507089f702eb24b506be2ce7e0efd
|
||||
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 75deaa442f3a363c4ea5b6f0e510306feeaa8915
|
||||
R 62a9176bcf4a5c57a6633d26293ede50
|
||||
P 59be34cfa4fe74f7e5b547c55d273ecba9d7796c
|
||||
R f3d27e1b16af35370468dd13d616f41c
|
||||
U danielk1977
|
||||
Z 89134c443f08e4715d35e3ebe96ef424
|
||||
Z c019239d82228e28c9df258ace82b690
|
||||
|
@ -1 +1 @@
|
||||
59be34cfa4fe74f7e5b547c55d273ecba9d7796c
|
||||
0c8b74e668b7462c5439c04993d1d7cd74210075
|
37
src/btree.c
37
src/btree.c
@ -9,7 +9,7 @@
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** $Id: btree.c,v 1.515 2008/09/19 15:10:58 danielk1977 Exp $
|
||||
** $Id: btree.c,v 1.516 2008/09/19 16:39:38 danielk1977 Exp $
|
||||
**
|
||||
** This file implements a external (disk-based) database using BTrees.
|
||||
** See the header comment on "btreeInt.h" for additional information.
|
||||
@ -3564,8 +3564,22 @@ static int moveToRoot(BtCursor *pCur){
|
||||
clearCursorPosition(pCur);
|
||||
}
|
||||
pRoot = pCur->pPage;
|
||||
if( pRoot && pRoot->pgno==pCur->pgnoRoot ){
|
||||
if( pRoot && pRoot->isInit ){
|
||||
/* If the page the cursor is currently pointing to is fully initialized,
|
||||
** then the root page can be found by following the MemPage.pParent
|
||||
** pointers. This is faster than requesting a reference to the root
|
||||
** page from the pager layer.
|
||||
*/
|
||||
while( pRoot->pParent ){
|
||||
assert( pRoot->isInit==PAGE_ISINIT_FULL );
|
||||
pRoot = pRoot->pParent;
|
||||
}
|
||||
assert( pRoot->isInit==PAGE_ISINIT_FULL );
|
||||
if( pRoot!=pCur->pPage ){
|
||||
sqlite3PagerRef(pRoot->pDbPage);
|
||||
releasePage(pCur->pPage);
|
||||
pCur->pPage = pRoot;
|
||||
}
|
||||
}else{
|
||||
if(
|
||||
SQLITE_OK!=(rc = getAndInitPage(pBt, pCur->pgnoRoot, &pRoot, 0))
|
||||
@ -3576,6 +3590,7 @@ static int moveToRoot(BtCursor *pCur){
|
||||
releasePage(pCur->pPage);
|
||||
pCur->pPage = pRoot;
|
||||
}
|
||||
assert( pCur->pPage->pgno==pCur->pgnoRoot );
|
||||
pCur->idx = 0;
|
||||
pCur->info.nSize = 0;
|
||||
pCur->atLast = 0;
|
||||
@ -3745,7 +3760,6 @@ int sqlite3BtreeMovetoUnpacked(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
rc = moveToRoot(pCur);
|
||||
if( rc ){
|
||||
return rc;
|
||||
@ -6472,18 +6486,29 @@ int sqlite3BtreeGetMeta(Btree *p, int idx, u32 *pMeta){
|
||||
}
|
||||
|
||||
assert( idx>=0 && idx<=15 );
|
||||
if( !pBt->pPage1 ){
|
||||
if( pBt->pPage1 ){
|
||||
/* The b-tree is already holding a reference to page 1 of the database
|
||||
** file. In this case the required meta-data value can be read directly
|
||||
** from the page data of this reference. This is slightly faster than
|
||||
** requesting a new reference from the pager layer.
|
||||
*/
|
||||
pP1 = (unsigned char *)pBt->pPage1->aData;
|
||||
}else{
|
||||
/* The b-tree does not have a reference to page 1 of the database file.
|
||||
** Obtain one from the pager layer.
|
||||
*/
|
||||
rc = sqlite3PagerGet(pBt->pPager, 1, &pDbPage);
|
||||
if( rc ){
|
||||
sqlite3BtreeLeave(p);
|
||||
return rc;
|
||||
}
|
||||
pP1 = (unsigned char *)sqlite3PagerGetData(pDbPage);
|
||||
}else{
|
||||
pP1 = (unsigned char *)pBt->pPage1->aData;
|
||||
}
|
||||
*pMeta = get4byte(&pP1[36 + idx*4]);
|
||||
|
||||
/* If the b-tree is not holding a reference to page 1, then one was
|
||||
** requested from the pager layer in the above block. Release it now.
|
||||
*/
|
||||
if( !pBt->pPage1 ){
|
||||
sqlite3PagerUnref(pDbPage);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user