Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | 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) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
0c8b74e668b7462c5439c04993d1d7cd |
User & Date: | danielk1977 2008-09-19 16:39:38.000 |
Context
2008-09-19
| ||
18:32 | Speed up releaseMemArray() a bit by handling the most common types of memory cells inline. (CVS 5726) (check-in: ce07508550 user: danielk1977 tags: trunk) | |
16:39 | 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) (check-in: 0c8b74e668 user: danielk1977 tags: trunk) | |
15:10 | In sqlite3BtreeGetMeta(), if BtShared.pPage1 is available use it instead of requesting a new reference from the pager layer. (CVS 5724) (check-in: 59be34cfa4 user: danielk1977 tags: trunk) | |
Changes
Changes to src/btree.c.
1 2 3 4 5 6 7 8 9 10 11 | /* ** 2004 April 6 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /* ** 2004 April 6 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** $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. ** Including a description of file format and an overview of operation. */ #include "btreeInt.h" |
︙ | ︙ | |||
3560 3561 3562 3563 3564 3565 3566 | if( pCur->eState>=CURSOR_REQUIRESEEK ){ if( pCur->eState==CURSOR_FAULT ){ return pCur->skip; } clearCursorPosition(pCur); } pRoot = pCur->pPage; | | > > > > > > | > > > > > > > > > | 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 | if( pCur->eState>=CURSOR_REQUIRESEEK ){ if( pCur->eState==CURSOR_FAULT ){ return pCur->skip; } clearCursorPosition(pCur); } pRoot = pCur->pPage; 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)) ){ pCur->eState = CURSOR_INVALID; return rc; } releasePage(pCur->pPage); pCur->pPage = pRoot; } assert( pCur->pPage->pgno==pCur->pgnoRoot ); pCur->idx = 0; pCur->info.nSize = 0; pCur->atLast = 0; pCur->validNKey = 0; if( pRoot->nCell==0 && !pRoot->leaf ){ Pgno subpage; assert( pRoot->pgno==1 ); |
︙ | ︙ | |||
3740 3741 3742 3743 3744 3745 3746 | return SQLITE_OK; } if( pCur->atLast && pCur->info.nKey<intKey ){ *pRes = -1; return SQLITE_OK; } } | < | 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 | return SQLITE_OK; } if( pCur->atLast && pCur->info.nKey<intKey ){ *pRes = -1; return SQLITE_OK; } } rc = moveToRoot(pCur); if( rc ){ return rc; } assert( pCur->pPage ); assert( pCur->pPage->isInit==PAGE_ISINIT_FULL ); |
︙ | ︙ | |||
6468 6469 6470 6471 6472 6473 6474 | rc = queryTableLock(p, 1, READ_LOCK); if( rc!=SQLITE_OK ){ sqlite3BtreeLeave(p); return rc; } assert( idx>=0 && idx<=15 ); | | > > > > > > > > > > < < > > > | 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 | rc = queryTableLock(p, 1, READ_LOCK); if( rc!=SQLITE_OK ){ sqlite3BtreeLeave(p); return rc; } assert( idx>=0 && idx<=15 ); 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); } *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); } /* If autovacuumed is disabled in this build but we are trying to ** access an autovacuumed database, then make the database readonly. */ |
︙ | ︙ |