Compare commits

...

1 Commits

Author SHA1 Message Date
drh 56747e79f1 Experimental change to ANALYZE so that when computing values for
sqlite_stat1, it uses the maximum number for the number of rows
having equivalent values, rather than the average.

FossilOrigin-Name: 085f17e124d183d1da371250f24988aed5697924e7950162bb6f0bb514298e2a
2018-07-20 18:01:21 +00:00
3 changed files with 28 additions and 9 deletions
+9 -6
View File
@@ -1,5 +1,5 @@
C New\schecked\sin\sPRAGMA\sintegrity_check\sto\svalidate\sthe\sautovacuum\ssettings\nin\sthe\sheader.
D 2018-07-20T15:44:09.800
C Experimental\schange\sto\sANALYZE\sso\sthat\swhen\scomputing\svalues\sfor\nsqlite_stat1,\sit\suses\sthe\smaximum\snumber\sfor\sthe\snumber\sof\srows\nhaving\sequivalent\svalues,\srather\sthan\sthe\saverage.
D 2018-07-20T18:01:21.815
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F Makefile.in 0a3a6c81e6fcb969ff9106e882f0a08547014ba463cb6beca4c4efaecc924ee6
@@ -432,7 +432,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b
F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786
F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a
F src/alter.c 6beb476095a4cfeb95ebedb2e5e17894d1687b24fddd5b8761a4de120e0392c6
F src/analyze.c 91b5e7c0f4a08dbb1f7a24b24e7ab49be8b0a2fd1906a35add62a855d1c0ceb9
F src/analyze.c 3c64f4f1fab8c4b7ff65b20d02c6d77f4cc7bc2062a1e13a39d36d41265563ce
F src/attach.c 4bd5b92633671d3e8ce431153ebb1893b50335818423b5373f3f27969f79769a
F src/auth.c a38f3c63c974787ecf75e3213f8cac6568b9a7af7591fb0372ec0517dd16dca8
F src/backup.c 78d3cecfbe28230a3a9a1793e2ead609f469be43e8f486ca996006be551857ab
@@ -1750,7 +1750,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 11e58f5b37d99848978007d834d187c262d904eb9d58924742e028d7cb324e64
R c0acde69723fe0b5e3fbc25297e0d544
P a4663f09c91d1381a831f61a2b8e8a113eb6083932c4aea2ad0c011ece1418c5
R 9176e525d49b405a632d9f859c83ded1
T *branch * stat1-max
T *sym-stat1-max *
T -sym-trunk *
U drh
Z 0f08918d98de0383295ceae1a107394a
Z 7117cc07373fb53670e1da8778a77fae
+1 -1
View File
@@ -1 +1 @@
a4663f09c91d1381a831f61a2b8e8a113eb6083932c4aea2ad0c011ece1418c5
085f17e124d183d1da371250f24988aed5697924e7950162bb6f0bb514298e2a
+18 -2
View File
@@ -271,6 +271,7 @@ typedef struct Stat4Sample Stat4Sample;
struct Stat4Sample {
tRowcnt *anEq; /* sqlite_stat4.nEq */
tRowcnt *anDLt; /* sqlite_stat4.nDLt */
tRowcnt *amxEq; /* Maximum vlaues for anEq[] */
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
tRowcnt *anLt; /* sqlite_stat4.nLt */
union {
@@ -424,6 +425,7 @@ static void statInit(
n = sizeof(*p)
+ sizeof(tRowcnt)*nColUp /* Stat4Accum.anEq */
+ sizeof(tRowcnt)*nColUp /* Stat4Accum.anDLt */
+ sizeof(tRowcnt)*nColUp /* Stat4Accum.amxEq */
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
+ sizeof(tRowcnt)*nColUp /* Stat4Accum.anLt */
+ sizeof(Stat4Sample)*(nCol+mxSample) /* Stat4Accum.aBest[], a[] */
@@ -442,7 +444,8 @@ static void statInit(
p->nCol = nCol;
p->nKeyCol = nKeyCol;
p->current.anDLt = (tRowcnt*)&p[1];
p->current.anEq = &p->current.anDLt[nColUp];
p->current.amxEq = &p->current.anDLt[nColUp];
p->current.anEq = &p->current.amxEq[nColUp];
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
{
@@ -744,7 +747,10 @@ static void statPush(
if( p->nRow==0 ){
/* This is the first call to this function. Do initialization. */
for(i=0; i<p->nCol; i++) p->current.anEq[i] = 1;
for(i=0; i<p->nCol; i++){
p->current.anEq[i] = 1;
p->current.amxEq[i] = 1;
}
}else{
/* Second and subsequent calls get processed here */
samplePushPrevious(p, iChng);
@@ -759,6 +765,9 @@ static void statPush(
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
p->current.anLt[i] += p->current.anEq[i];
#endif
if( p->current.amxEq[i]<p->current.anEq[i] ){
p->current.amxEq[i] = p->current.anEq[i];
}
p->current.anEq[i] = 1;
}
}
@@ -884,11 +893,18 @@ static void statGet(
sqlite3_snprintf(24, zRet, "%llu", (u64)p->nRow);
z = zRet + sqlite3Strlen30(zRet);
for(i=0; i<p->nKeyCol; i++){
#if 0
u64 nDistinct = p->current.anDLt[i] + 1;
u64 iVal = (p->nRow + nDistinct - 1) / nDistinct;
sqlite3_snprintf(24, z, " %llu", iVal);
z += sqlite3Strlen30(z);
assert( p->current.anEq[i] );
#else
u64 iVal = p->current.amxEq[i];
if( iVal<p->current.anEq[i] ) iVal = p->current.anEq[i];
sqlite3_snprintf(24, z, " %llu", iVal);
z += sqlite3Strlen30(z);
#endif
}
assert( z[0]=='\0' && z>zRet );