1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Another optimization to the btree logic. (CVS 811)

FossilOrigin-Name: 03d20673616cae0dca524fd04557798a98fb7069
This commit is contained in:
drh
2003-01-04 18:53:27 +00:00
parent 428ae8cb41
commit bb49aba82a
3 changed files with 20 additions and 22 deletions

View File

@@ -1,5 +1,5 @@
C Optimizations\sto\sthe\sBTree\smodule\sfor\sa\smodest\sspeed\simprovement.\s(CVS\s810) C Another\soptimization\sto\sthe\sbtree\slogic.\s(CVS\s811)
D 2003-01-04T16:48:09 D 2003-01-04T18:53:28
F Makefile.in 868c17a1ae1c07603d491274cc8f86c04acf2a1e F Makefile.in 868c17a1ae1c07603d491274cc8f86c04acf2a1e
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -18,7 +18,7 @@ F main.mk 9d13839b9697af332d788fe6e801e68da027cc5c
F publish.sh e5b83867d14708ed58cec8cba0a4f201e969474d F publish.sh e5b83867d14708ed58cec8cba0a4f201e969474d
F spec.template 238f7db425a78dc1bb7682e56e3834c7270a3f5e F spec.template 238f7db425a78dc1bb7682e56e3834c7270a3f5e
F sqlite.1 83f4a9d37bdf2b7ef079a82d54eaf2e3509ee6ea F sqlite.1 83f4a9d37bdf2b7ef079a82d54eaf2e3509ee6ea
F src/btree.c 4ed13ad0c695e4fb803d106926c6fdd08a0b4d0f F src/btree.c 9ae3232125d54e0f4c73ae88af1f4556e15440e9
F src/btree.h 17710339f7a8f46e3c7d6d0d4648ef19c584ffda F src/btree.h 17710339f7a8f46e3c7d6d0d4648ef19c584ffda
F src/build.c 8569ac014609add4b796260d3567a5090b90056d F src/build.c 8569ac014609add4b796260d3567a5090b90056d
F src/delete.c aad9d4051ab46e6f6391ea5f7b8994a7c05bdd15 F src/delete.c aad9d4051ab46e6f6391ea5f7b8994a7c05bdd15
@@ -152,7 +152,7 @@ F www/speed.tcl a20a792738475b68756ea7a19321600f23d1d803
F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098 F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098
F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331 F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
P 1ba41bc2afab18cc295d9a45845296b46bfa57e5 P 39902a70417475225956704a037493515e9b08b9
R a4125fbf39c245763f99492b33c9c8e8 R 5307d3e389db7bcbbe208e92a667a5a5
U drh U drh
Z df8ce8a4e13ca11e4b128387a80bf533 Z 5237255ce20b25abc6c29c72daee1d77

View File

@@ -1 +1 @@
39902a70417475225956704a037493515e9b08b9 03d20673616cae0dca524fd04557798a98fb7069

View File

@@ -9,7 +9,7 @@
** May you share freely, never taking more than you give. ** May you share freely, never taking more than you give.
** **
************************************************************************* *************************************************************************
** $Id: btree.c,v 1.77 2003/01/04 16:48:09 drh Exp $ ** $Id: btree.c,v 1.78 2003/01/04 18:53:28 drh Exp $
** **
** This file implements a external (disk-based) database using BTrees. ** This file implements a external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to ** For a detailed discussion of BTrees, refer to
@@ -2123,7 +2123,6 @@ static int balance(Btree *pBt, MemPage *pPage, BtCursor *pCur){
int cntNew[4]; /* Index in apCell[] of cell after i-th page */ int cntNew[4]; /* Index in apCell[] of cell after i-th page */
int szNew[4]; /* Combined size of cells place on i-th page */ int szNew[4]; /* Combined size of cells place on i-th page */
MemPage *extraUnref = 0; /* A page that needs to be unref-ed */ MemPage *extraUnref = 0; /* A page that needs to be unref-ed */
Pgno pgno, swabPgno; /* Page number */
Cell *apCell[MX_CELL*3+5]; /* All cells from pages being balanceed */ Cell *apCell[MX_CELL*3+5]; /* All cells from pages being balanceed */
int szCell[MX_CELL*3+5]; /* Local size of all cells */ int szCell[MX_CELL*3+5]; /* Local size of all cells */
Cell aTemp[2]; /* Temporary holding area for apDiv[] */ Cell aTemp[2]; /* Temporary holding area for apDiv[] */
@@ -2198,7 +2197,7 @@ static int balance(Btree *pBt, MemPage *pPage, BtCursor *pCur){
assert( sqlitepager_iswriteable(pChild) ); assert( sqlitepager_iswriteable(pChild) );
copyPage(pChild, pPage); copyPage(pChild, pPage);
pChild->pParent = pPage; pChild->pParent = pPage;
pChild->idxParent = pChild->nCell; pChild->idxParent = 0;
sqlitepager_ref(pPage); sqlitepager_ref(pPage);
pChild->isOverfull = 1; pChild->isOverfull = 1;
if( pCur && pCur->pPage==pPage ){ if( pCur && pCur->pPage==pPage ){
@@ -2221,20 +2220,19 @@ static int balance(Btree *pBt, MemPage *pPage, BtCursor *pCur){
** to pPage. The "idx" variable is the index of that cell. If pPage ** to pPage. The "idx" variable is the index of that cell. If pPage
** is the rightmost child of pParent then set idx to pParent->nCell ** is the rightmost child of pParent then set idx to pParent->nCell
*/ */
idx = -1; if( pParent->idxShift ){
pgno = sqlitepager_pagenumber(pPage); Pgno pgno, swabPgno;
swabPgno = SWAB32(pBt, pgno); pgno = sqlitepager_pagenumber(pPage);
for(i=0; i<pParent->nCell; i++){ swabPgno = SWAB32(pBt, pgno);
if( pParent->apCell[i]->h.leftChild==swabPgno ){ for(idx=0; idx<pParent->nCell; idx++){
idx = i; if( pParent->apCell[idx]->h.leftChild==swabPgno ){
break; break;
}
} }
assert( idx<pParent->nCell || pParent->u.hdr.rightChild==swabPgno );
}else{
idx = pPage->idxParent;
} }
if( idx<0 && pParent->u.hdr.rightChild==swabPgno ){
idx = pParent->nCell;
}
assert( idx>=0 );
/* assert( pParent->idxShift || idx==pPage->idxParent ); */
/* /*
** Initialize variables so that it will be safe to jump ** Initialize variables so that it will be safe to jump