Remove some unnecessary computations from ANALYZE so that ANALYZE runs with
fewer CPU cycles. These changes were spotted while working on the nearby enhanced-stat1 branch. So even if enhanced-stat1 is abandoned, that effort put into it will not have been in vain. FossilOrigin-Name: 5527e8c4abb904b1a438ec1c353d4a960bf82faaf3a2c742af1df7c613850441
This commit is contained in:
parent
4ccf707c6e
commit
4cfc19f34c
15
manifest
15
manifest
@ -1,5 +1,5 @@
|
|||||||
C Extra\ssteps\staken\sto\savoid\susing\slow-quality\sindexes\sin\sa\squery\splan.\nThis\sbranch\saccomplishes\sthe\ssame\send\sas\sthe\snearby\senhanced-stat1\sbranch,\nbut\swith\smuch\sless\schange\sand\shence\sless\srisk.
|
C Remove\ssome\sunnecessary\scomputations\sfrom\sANALYZE\sso\sthat\sANALYZE\sruns\swith\nfewer\sCPU\scycles.\s\sThese\schanges\swere\sspotted\swhile\sworking\son\sthe\snearby\nenhanced-stat1\sbranch.\s\sSo\seven\sif\senhanced-stat1\sis\sabandoned,\sthat\seffort\nput\sinto\sit\swill\snot\shave\sbeen\sin\svain.
|
||||||
D 2024-01-01T17:48:02.427
|
D 2024-01-01T17:58:57.875
|
||||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||||
@ -670,7 +670,7 @@ F sqlite3.1 acdff36db796e2d00225b911d3047d580cd136547298435426ce9d40347973cc
|
|||||||
F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a
|
F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a
|
||||||
F sqlite_cfg.h.in baf2e409c63d4e7a765e17769b6ff17c5a82bbd9cbf1e284fd2e4cefaff3fcf2
|
F sqlite_cfg.h.in baf2e409c63d4e7a765e17769b6ff17c5a82bbd9cbf1e284fd2e4cefaff3fcf2
|
||||||
F src/alter.c 30c2333b8bb3af71e4eb9adeadee8aa20edb15917ed44b8422e5cd15f3dfcddc
|
F src/alter.c 30c2333b8bb3af71e4eb9adeadee8aa20edb15917ed44b8422e5cd15f3dfcddc
|
||||||
F src/analyze.c 64ac1dd3b7044c7a7981a5f6d3796bc007b7e31514c674283bf440586681501e
|
F src/analyze.c 0f15753308c3bca7674f31fa7e0807ffcb8b120c36eef7d00b62b33079ddc854
|
||||||
F src/attach.c cc9d00d30da916ff656038211410ccf04ed784b7564639b9b61d1839ed69fd39
|
F src/attach.c cc9d00d30da916ff656038211410ccf04ed784b7564639b9b61d1839ed69fd39
|
||||||
F src/auth.c 19b7ccacae3dfba23fc6f1d0af68134fa216e9040e53b0681b4715445ea030b4
|
F src/auth.c 19b7ccacae3dfba23fc6f1d0af68134fa216e9040e53b0681b4715445ea030b4
|
||||||
F src/backup.c 5c97e8023aab1ce14a42387eb3ae00ba5a0644569e3476f38661fa6f824c3523
|
F src/backup.c 5c97e8023aab1ce14a42387eb3ae00ba5a0644569e3476f38661fa6f824c3523
|
||||||
@ -2156,11 +2156,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
|||||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||||
P dc501275fcfab3ad9b6ebbadf7588b225a9dd07a0abac5be83d96f15bfba99e9
|
P c030e646262fee43a59b45fdc1630d972f8bf88ac3c142b6bdaf4cbb36695a4f
|
||||||
R 4e0f7b3b61e72c244a187959e2e9f486
|
R a1cdb8f6aed6a59edfbfbd0410b4be3d
|
||||||
T *branch * avoid-low-quality-indexes
|
|
||||||
T *sym-avoid-low-quality-indexes *
|
|
||||||
T -sym-trunk *
|
|
||||||
U drh
|
U drh
|
||||||
Z ac10d23b30667bc4467501c1b744109a
|
Z fe0456d193300bdd1fb2616e0f9641df
|
||||||
# Remove this line to create a well-formed Fossil manifest.
|
# Remove this line to create a well-formed Fossil manifest.
|
||||||
|
@ -1 +1 @@
|
|||||||
c030e646262fee43a59b45fdc1630d972f8bf88ac3c142b6bdaf4cbb36695a4f
|
5527e8c4abb904b1a438ec1c353d4a960bf82faaf3a2c742af1df7c613850441
|
@ -264,9 +264,9 @@ static void openStatTable(
|
|||||||
typedef struct StatAccum StatAccum;
|
typedef struct StatAccum StatAccum;
|
||||||
typedef struct StatSample StatSample;
|
typedef struct StatSample StatSample;
|
||||||
struct StatSample {
|
struct StatSample {
|
||||||
tRowcnt *anEq; /* sqlite_stat4.nEq */
|
|
||||||
tRowcnt *anDLt; /* sqlite_stat4.nDLt */
|
tRowcnt *anDLt; /* sqlite_stat4.nDLt */
|
||||||
#ifdef SQLITE_ENABLE_STAT4
|
#ifdef SQLITE_ENABLE_STAT4
|
||||||
|
tRowcnt *anEq; /* sqlite_stat4.nEq */
|
||||||
tRowcnt *anLt; /* sqlite_stat4.nLt */
|
tRowcnt *anLt; /* sqlite_stat4.nLt */
|
||||||
union {
|
union {
|
||||||
i64 iRowid; /* Rowid in main table of the key */
|
i64 iRowid; /* Rowid in main table of the key */
|
||||||
@ -424,9 +424,9 @@ static void statInit(
|
|||||||
|
|
||||||
/* Allocate the space required for the StatAccum object */
|
/* Allocate the space required for the StatAccum object */
|
||||||
n = sizeof(*p)
|
n = sizeof(*p)
|
||||||
+ sizeof(tRowcnt)*nColUp /* StatAccum.anEq */
|
|
||||||
+ sizeof(tRowcnt)*nColUp; /* StatAccum.anDLt */
|
+ sizeof(tRowcnt)*nColUp; /* StatAccum.anDLt */
|
||||||
#ifdef SQLITE_ENABLE_STAT4
|
#ifdef SQLITE_ENABLE_STAT4
|
||||||
|
n += sizeof(tRowcnt)*nColUp; /* StatAccum.anEq */
|
||||||
if( mxSample ){
|
if( mxSample ){
|
||||||
n += sizeof(tRowcnt)*nColUp /* StatAccum.anLt */
|
n += sizeof(tRowcnt)*nColUp /* StatAccum.anLt */
|
||||||
+ sizeof(StatSample)*(nCol+mxSample) /* StatAccum.aBest[], a[] */
|
+ sizeof(StatSample)*(nCol+mxSample) /* StatAccum.aBest[], a[] */
|
||||||
@ -447,9 +447,9 @@ static void statInit(
|
|||||||
p->nKeyCol = nKeyCol;
|
p->nKeyCol = nKeyCol;
|
||||||
p->nSkipAhead = 0;
|
p->nSkipAhead = 0;
|
||||||
p->current.anDLt = (tRowcnt*)&p[1];
|
p->current.anDLt = (tRowcnt*)&p[1];
|
||||||
p->current.anEq = &p->current.anDLt[nColUp];
|
|
||||||
|
|
||||||
#ifdef SQLITE_ENABLE_STAT4
|
#ifdef SQLITE_ENABLE_STAT4
|
||||||
|
p->current.anEq = &p->current.anDLt[nColUp];
|
||||||
p->mxSample = p->nLimit==0 ? mxSample : 0;
|
p->mxSample = p->nLimit==0 ? mxSample : 0;
|
||||||
if( mxSample ){
|
if( mxSample ){
|
||||||
u8 *pSpace; /* Allocated space not yet assigned */
|
u8 *pSpace; /* Allocated space not yet assigned */
|
||||||
@ -716,7 +716,9 @@ static void statPush(
|
|||||||
|
|
||||||
if( p->nRow==0 ){
|
if( p->nRow==0 ){
|
||||||
/* This is the first call to this function. Do initialization. */
|
/* This is the first call to this function. Do initialization. */
|
||||||
|
#ifdef SQLITE_ENABLE_STAT4
|
||||||
for(i=0; i<p->nCol; i++) p->current.anEq[i] = 1;
|
for(i=0; i<p->nCol; i++) p->current.anEq[i] = 1;
|
||||||
|
#endif
|
||||||
}else{
|
}else{
|
||||||
/* Second and subsequent calls get processed here */
|
/* Second and subsequent calls get processed here */
|
||||||
#ifdef SQLITE_ENABLE_STAT4
|
#ifdef SQLITE_ENABLE_STAT4
|
||||||
@ -725,15 +727,17 @@ static void statPush(
|
|||||||
|
|
||||||
/* Update anDLt[], anLt[] and anEq[] to reflect the values that apply
|
/* Update anDLt[], anLt[] and anEq[] to reflect the values that apply
|
||||||
** to the current row of the index. */
|
** to the current row of the index. */
|
||||||
|
#ifdef SQLITE_ENABLE_STAT4
|
||||||
for(i=0; i<iChng; i++){
|
for(i=0; i<iChng; i++){
|
||||||
p->current.anEq[i]++;
|
p->current.anEq[i]++;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
for(i=iChng; i<p->nCol; i++){
|
for(i=iChng; i<p->nCol; i++){
|
||||||
p->current.anDLt[i]++;
|
p->current.anDLt[i]++;
|
||||||
#ifdef SQLITE_ENABLE_STAT4
|
#ifdef SQLITE_ENABLE_STAT4
|
||||||
if( p->mxSample ) p->current.anLt[i] += p->current.anEq[i];
|
if( p->mxSample ) p->current.anLt[i] += p->current.anEq[i];
|
||||||
#endif
|
|
||||||
p->current.anEq[i] = 1;
|
p->current.anEq[i] = 1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -867,7 +871,9 @@ static void statGet(
|
|||||||
u64 iVal = (p->nRow + nDistinct - 1) / nDistinct;
|
u64 iVal = (p->nRow + nDistinct - 1) / nDistinct;
|
||||||
if( iVal==2 && p->nRow*10 <= nDistinct*11 ) iVal = 1;
|
if( iVal==2 && p->nRow*10 <= nDistinct*11 ) iVal = 1;
|
||||||
sqlite3_str_appendf(&sStat, " %llu", iVal);
|
sqlite3_str_appendf(&sStat, " %llu", iVal);
|
||||||
|
#ifdef SQLITE_ENABLE_STAT4
|
||||||
assert( p->current.anEq[i] );
|
assert( p->current.anEq[i] );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
sqlite3ResultStrAccum(context, &sStat);
|
sqlite3ResultStrAccum(context, &sStat);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user