aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <>2024-02-18 01:12:22 +0000
committerdrh <>2024-02-18 01:12:22 +0000
commitd43e7adca7eb5d8c1ac6b345aa2470ed0f8b2c06 (patch)
treed31c44c080f978ead31e292625dfdd9146059199 /src
parent42eb6a91cdb5fe221171e7a0e588abd73d50542d (diff)
downloadsqlite-d43e7adca7eb5d8c1ac6b345aa2470ed0f8b2c06.tar.gz
sqlite-d43e7adca7eb5d8c1ac6b345aa2470ed0f8b2c06.zip
Hold a transaction during PRAGMA optimize, for performance.
FossilOrigin-Name: d13b79eae6df7f9d1f3b8062ddc75a12ff038196b3d752d2672a9925fa45ca56
Diffstat (limited to 'src')
-rw-r--r--src/pragma.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/pragma.c b/src/pragma.c
index 40a31846b..9bb971ed7 100644
--- a/src/pragma.c
+++ b/src/pragma.c
@@ -2446,6 +2446,7 @@ void sqlite3Pragma(
char *zSubSql; /* SQL statement for the OP_SqlExec opcode */
u32 opMask; /* Mask of operations to perform */
int nLimit; /* Analysis limit to use */
+ int once = 0; /* One-time initialization done */
#ifndef SQLITE_DEFAULT_OPTIMIZE_LIMIT
# define SQLITE_DEFAULT_OPTIMIZE_LIMIT 400
@@ -2488,6 +2489,12 @@ void sqlite3Pragma(
continue;
}
+ /* Hold a write transaction open for efficiency */
+ if( !once ){
+ sqlite3BeginWriteOperation(pParse, 0, iDb);
+ once = 1;
+ }
+
/* Reanalyze if the table is 25 times larger than the last analysis */
szThreshold = pTab->nRowLogEst;
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){