Index: src/btree.c ================================================================== --- src/btree.c +++ src/btree.c @@ -7,11 +7,11 @@ ** 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.382 2007/05/16 17:28:43 danielk1977 Exp $ +** $Id: btree.c,v 1.383 2007/05/17 18:28:11 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. */ @@ -3841,14 +3841,25 @@ pPayload = &pCell[nHeader]; pPrior = &pCell[info.iOverflow]; while( nPayload>0 ){ if( spaceLeft==0 ){ + int isExact = 0; #ifndef SQLITE_OMIT_AUTOVACUUM Pgno pgnoPtrmap = pgnoOvfl; /* Overflow page pointer-map entry page */ + if( pBt->autoVacuum ){ + do{ + pgnoOvfl++; + } while( + PTRMAP_ISPAGE(pBt, pgnoOvfl) || pgnoOvfl==PENDING_BYTE_PAGE(pBt) + ); + if( pgnoOvfl>1 ){ + /* isExact = 1; */ + } + } #endif - rc = allocateBtreePage(pBt, &pOvfl, &pgnoOvfl, pgnoOvfl, 0); + rc = allocateBtreePage(pBt, &pOvfl, &pgnoOvfl, pgnoOvfl, isExact); #ifndef SQLITE_OMIT_AUTOVACUUM /* If the database supports auto-vacuum, and the second or subsequent ** overflow page is being allocated, add an entry to the pointer-map ** for that page now. The entry for the first overflow page will be ** added later, by the insertCell() routine. Index: test/speed3.test ================================================================== --- test/speed3.test +++ test/speed3.test @@ -10,11 +10,11 @@ #************************************************************************* # This file implements regression tests for SQLite library. The # focus of this script is testing that the overflow-page related # enhancements added after version 3.3.17 speed things up. # -# $Id: speed3.test,v 1.1 2007/05/17 14:45:13 danielk1977 Exp $ +# $Id: speed3.test,v 1.2 2007/05/17 18:28:11 danielk1977 Exp $ # #--------------------------------------------------------------------- # Test plan: # @@ -94,10 +94,22 @@ # puts "1: [array get stats1]" # puts "2: [array get stats2]" puts "Incrvacuum: Read $stats1(read), wrote $stats1(write)" puts "Normal : Read $stats2(read), wrote $stats2(write)" } + +proc overflow_report {db} { + set bt [btree_from_db db] + set csr [btree_cursor $bt 3 0] + + for {btree_first $csr} {![btree_eof $csr]} {btree_next $csr} { + puts "[btree_ovfl_info $bt $csr]" + } + + btree_close_cursor $csr + +} proc reset_db {} { db close sqlite3 db test.db db eval { @@ -144,22 +156,24 @@ } {2 0} # Delete all content in a table, one row at a time. # #io_log db +#overflow_report db reset_db speed_trial speed3-1.incrvacuum $::NROW row {DELETE FROM main.t1 WHERE 1} speed_trial speed3-1.normal $::NROW row {DELETE FROM aux.t1 WHERE 1} io_log db # Select the "C" column (located at the far end of the overflow # chain) from each table row. # -db eval {PRAGMA incremental_vacuum(500000)} +#db eval {PRAGMA incremental_vacuum(500000)} populate_t1 db +#overflow_report db reset_db speed_trial speed3-2.incrvacuum $::NROW row {SELECT c FROM main.t1} speed_trial speed3-2.normal $::NROW row {SELECT c FROM aux.t1} io_log db finish_test