mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Avoid unnecessary calls to balance() from sqlite3BtreeDelete().
FossilOrigin-Name: d0966d1bdd474e27cb048884d340184f0e81a4fab65eb6b74682b20630caddf8
This commit is contained in:
12
manifest
12
manifest
@@ -1,5 +1,5 @@
|
||||
C Fix\sthe\ssqlite3_result_xxxxx()\sroutines\sso\sthat\sthey\sall\scheck\sfor\sand\nperform\sany\snecessary\stext\sencoding\sconversions\sand\scheck\sfor\soversize\nstrings\sand\sBLOBs.\s\sThus\sthose\schecks\scan\sbe\sdone\swhere\sthey\sare\smost\nefficient\sand\savoided\sin\scases\slike\sOP_Function\swhere\sthey\sare\smore\nexpensive.
|
||||
D 2022-03-29T01:43:09.917
|
||||
C Avoid\sunnecessary\scalls\sto\sbalance()\sfrom\ssqlite3BtreeDelete().
|
||||
D 2022-03-29T13:16:32.297
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@@ -492,7 +492,7 @@ F src/auth.c f4fa91b6a90bbc8e0d0f738aa284551739c9543a367071f55574681e0f24f8cf
|
||||
F src/backup.c a2891172438e385fdbe97c11c9745676bec54f518d4447090af97189fd8e52d7
|
||||
F src/bitvec.c 7c849aac407230278445cb069bebc5f89bf2ddd87c5ed9459b070a9175707b3d
|
||||
F src/btmutex.c 8acc2f464ee76324bf13310df5692a262b801808984c1b79defb2503bbafadb6
|
||||
F src/btree.c 11a4719bbae5dc1da6d0e1e892302589420c054ad24ca523c10a66a39a123d06
|
||||
F src/btree.c 485157b77a8d841c16bff713380d2ce1375c2167f6824202e56f2715bf51c982
|
||||
F src/btree.h 74d64b8f28cfa4a894d14d4ed64fa432cd697b98b61708d4351482ae15913e22
|
||||
F src/btreeInt.h 8ce1332edd89dfd2461d561ac10a0ab5601c8e06200cb5230596c3caaf54482e
|
||||
F src/build.c a0cc68fe8172c0a31b54576f9c6c0fe6f7c82b1b5e1387afdd6a5a13132bc131
|
||||
@@ -1945,8 +1945,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P 310a3e102d8eedf92ee63ffffb48621abfb1e2736b96bd2a676d63cca0f40598
|
||||
R 36f3f4bc3d4f57fe3c73eaa6653f4db1
|
||||
P d50b162b2f2e320af0889b931351f9443580465a933f6657fa98f437b6579277
|
||||
R 760b6e4d465397c3b2d89a9054754f29
|
||||
U drh
|
||||
Z faba0725b64437f0f9101d235cb21291
|
||||
Z 254ff3a6f1f20ba9be417b9b988b6588
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
@@ -1 +1 @@
|
||||
d50b162b2f2e320af0889b931351f9443580465a933f6657fa98f437b6579277
|
||||
d0966d1bdd474e27cb048884d340184f0e81a4fab65eb6b74682b20630caddf8
|
17
src/btree.c
17
src/btree.c
@@ -8742,7 +8742,6 @@ static int anotherValidCursor(BtCursor *pCur){
|
||||
*/
|
||||
static int balance(BtCursor *pCur){
|
||||
int rc = SQLITE_OK;
|
||||
const int nMin = pCur->pBt->usableSize * 2 / 3;
|
||||
u8 aBalanceQuickSpace[13];
|
||||
u8 *pFree = 0;
|
||||
|
||||
@@ -8754,7 +8753,11 @@ static int balance(BtCursor *pCur){
|
||||
MemPage *pPage = pCur->pPage;
|
||||
|
||||
if( NEVER(pPage->nFree<0) && btreeComputeFreeSpace(pPage) ) break;
|
||||
if( pPage->nOverflow==0 && pPage->nFree<=nMin ){
|
||||
if( pPage->nOverflow==0 && pPage->nFree*3<=pCur->pBt->usableSize*2 ){
|
||||
/* No rebalance required as long as:
|
||||
** (1) There are no overflow cells
|
||||
** (2) The amount of free space on the page is less than 2/3rds of
|
||||
** the total usable space on the page. */
|
||||
break;
|
||||
}else if( (iPage = pCur->iPage)==0 ){
|
||||
if( pPage->nOverflow && (rc = anotherValidCursor(pCur))==SQLITE_OK ){
|
||||
@@ -9568,7 +9571,15 @@ int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
|
||||
** been corrected, so be it. Otherwise, after balancing the leaf node,
|
||||
** walk the cursor up the tree to the internal node and balance it as
|
||||
** well. */
|
||||
rc = balance(pCur);
|
||||
assert( pCur->pPage->nOverflow==0 );
|
||||
assert( pCur->pPage->nFree>=0 );
|
||||
if( pCur->pPage->nFree*3<=pCur->pBt->usableSize*2 ){
|
||||
/* Optimization: If the free space is less than 2/3rds of the page,
|
||||
** then balance() will always be a no-op. No need to invoke it. */
|
||||
rc = SQLITE_OK;
|
||||
}else{
|
||||
rc = balance(pCur);
|
||||
}
|
||||
if( rc==SQLITE_OK && pCur->iPage>iCellDepth ){
|
||||
releasePageNotNull(pCur->pPage);
|
||||
pCur->iPage--;
|
||||
|
Reference in New Issue
Block a user