From: drh Date: Thu, 25 Jun 2015 13:03:10 +0000 (+0000) Subject: Enhance the Btree object to remember whether or not it is holding an X-Git-Tag: version-3.8.11~126 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6918095d816d8e0eef2d3db520c1e49348020634;p=thirdparty%2Fsqlite.git Enhance the Btree object to remember whether or not it is holding an Incrblob cursor. Use this knowledge to improve performance in the common case where it does not. FossilOrigin-Name: 476b11563c08c6d9c0abd69e4d865c4edcdd45f5 --- diff --git a/manifest b/manifest index 1ee479c8b3..d294c30b1e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sa\sline\sof\scode\sthat\sdoesn't\sdo\sany\suseful\swork. -D 2015-06-25T02:26:45.202 +C Enhance\sthe\sBtree\sobject\sto\sremember\swhether\sor\snot\sit\sis\sholding\san\nIncrblob\scursor.\s\sUse\sthis\sknowledge\sto\simprove\sperformance\sin\sthe\scommon\ncase\swhere\sit\sdoes\snot. +D 2015-06-25T13:03:10.554 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 1063c58075b7400d93326b0eb332b48a54f53025 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -192,9 +192,9 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c ff743689c4d6c5cb55ad42ed9d174b2b3e71f1e3 F src/bitvec.c 5eb7958c3bf65210211cbcfc44eff86d0ded7c9d F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 -F src/btree.c a0eaf1139bbbb1f98abee448fb705c384a596075 +F src/btree.c 8a4109bdc6993507e95e3b377917a51a33b47027 F src/btree.h 969adc948e89e449220ff0ff724c94bb2a52e9f1 -F src/btreeInt.h 6ece2dd9c8e2eac05f0a8ded8772a44e96486c65 +F src/btreeInt.h fdd1aff02fb2a63812bd95716e7f579fc3759107 F src/build.c b3f15255d5b16e42dafeaa638fd4f8a47c94ed70 F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c a5cf5b4b56390cfb7b8636e8f7ddef90258dd575 @@ -1286,7 +1286,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P fad0eacc64b1810f60cab73bc88ba380f99e4b2d -R 1be92db979daaba09154bd51cdee9df8 +P 3ee888beb974e015bd11ae79381b208eaa310f6f +R 0fbef3ab0e1cedf4de8407e78df7b662 U drh -Z 4ec67a5cc5de328f0e5fd8e756e47fd0 +Z 765ae28d6062dc43145a9a4098bd20e0 diff --git a/manifest.uuid b/manifest.uuid index 86ab9a1da6..d2554ebcab 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3ee888beb974e015bd11ae79381b208eaa310f6f \ No newline at end of file +476b11563c08c6d9c0abd69e4d865c4edcdd45f5 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 50f5bfd916..23af2570cb 100644 --- a/src/btree.c +++ b/src/btree.c @@ -490,13 +490,15 @@ static void invalidateIncrblobCursors( int isClearTable /* True if all rows are being deleted */ ){ BtCursor *p; - BtShared *pBt = pBtree->pBt; + if( pBtree->hasIncrblobCur==0 ) return; assert( sqlite3BtreeHoldsMutex(pBtree) ); - for(p=pBt->pCursor; p; p=p->pNext){ - if( (p->curFlags & BTCF_Incrblob)!=0 - && (isClearTable || p->info.nKey==iRow) - ){ - p->eState = CURSOR_INVALID; + pBtree->hasIncrblobCur = 0; + for(p=pBtree->pBt->pCursor; p; p=p->pNext){ + if( (p->curFlags & BTCF_Incrblob)!=0 ){ + pBtree->hasIncrblobCur = 1; + if( isClearTable || p->info.nKey==iRow ){ + p->eState = CURSOR_INVALID; + } } } } @@ -9450,6 +9452,7 @@ int sqlite3BtreePutData(BtCursor *pCsr, u32 offset, u32 amt, void *z){ */ void sqlite3BtreeIncrblobCursor(BtCursor *pCur){ pCur->curFlags |= BTCF_Incrblob; + pCur->pBtree->hasIncrblobCur = 1; } #endif diff --git a/src/btreeInt.h b/src/btreeInt.h index 50c7db3a19..6fc8c45ea3 100644 --- a/src/btreeInt.h +++ b/src/btreeInt.h @@ -353,6 +353,7 @@ struct Btree { u8 inTrans; /* TRANS_NONE, TRANS_READ or TRANS_WRITE */ u8 sharable; /* True if we can share pBt with another db */ u8 locked; /* True if db currently has pBt locked */ + u8 hasIncrblobCur; /* True if there are one or more Incrblob cursors */ int wantToLock; /* Number of nested calls to sqlite3BtreeEnter() */ int nBackup; /* Number of backup operations reading this btree */ u32 iDataVersion; /* Combines with pBt->pPager->iDataVersion */