Improve the performance of ANALYZE when SQLITE_ENABLE_STAT4 is defined.

FossilOrigin-Name: 737a82444065752785c643b1d29ca097c828effb
This commit is contained in:
dan 2017-02-22 19:27:51 +00:00
parent 6bd166b81e
commit bd1d270ec9
3 changed files with 29 additions and 11 deletions

View File

@ -1,5 +1,5 @@
C Improvements\sto\sPRAGMA\sintegrity_check.\nVerify\sCHECK\sconstraints.\nVerify\sNOT\sNULL\sconstraints\seven\son\stable\sthat\slack\sindexes.\nVerify\sCHECK\sand\sNOT\sNULL\sconstraints\swith\sPRAGMA\squick_check.
D 2017-02-22T18:53:13.913
C Improve\sthe\sperformance\sof\sANALYZE\swhen\sSQLITE_ENABLE_STAT4\sis\sdefined.
D 2017-02-22T19:27:51.768
F Makefile.in edb6bcdd37748d2b1c3422ff727c748df7ffe918
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc a89ea37ab5928026001569f056973b9059492fe2
@ -332,7 +332,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b
F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786
F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a
F src/alter.c 3b23977620ce9662ac54443f65b87ba996e36121
F src/analyze.c ac7a5d7e3cee07d074697904e00e4a8ab7b2b4f5
F src/analyze.c 844359e720d1116592234f2f7938432bdc5b6238
F src/attach.c 8c476f8bd5d2afe11d925f890d30e527e5b0ce43
F src/auth.c 930b376a9c56998557367e6f7f8aaeac82a2a792
F src/backup.c faf17e60b43233c214aae6a8179d24503a61e83b
@ -1557,7 +1557,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 80adc0cb4ed7bacc54b15ac8b5b205403939c8c4 5af7d72ed9ec758283d78ceb46627d72021c1c60
R 46f90a15a015e3c65c6378dae6f8ff19
U drh
Z 9fac49478b578adef606b235c8c223db
P aa02bd3c95e374008b930d296c88dfafaf11c65a
R 767bcf2e23bb391de45c0ed55772662f
U dan
Z 11a6abc8e262f46553fa08a6e318d405

View File

@ -1 +1 @@
aa02bd3c95e374008b930d296c88dfafaf11c65a
737a82444065752785c643b1d29ca097c828effb

View File

@ -290,6 +290,7 @@ struct Stat4Accum {
Stat4Sample *aBest; /* Array of nCol best samples */
int iMin; /* Index in a[] of entry with minimum score */
int nSample; /* Current number of samples */
int nMaxEqZero; /* Max leading 0 in anEq[] for any a[] entry */
int iGet; /* Index of current sample accessed by stat_get() */
Stat4Sample *a; /* Array of mxSample Stat4Sample objects */
sqlite3 *db; /* Database connection, for malloc() */
@ -551,7 +552,14 @@ static void sampleInsert(Stat4Accum *p, Stat4Sample *pNew, int nEqZero){
Stat4Sample *pSample = 0;
int i;
/* Stat4Accum.nMaxEqZero is set to the maximum number of leading 0
** values in the anEq[] array of any sample in Stat4Accum.a[]. In
** other words, if nMaxEqZero is n, then it is guaranteed that there
** are no samples with Stat4Sample.anEq[m]==0 for (m>=n). */
assert( IsStat4 || nEqZero==0 );
if( nEqZero>p->nMaxEqZero ){
p->nMaxEqZero = nEqZero;
}
#ifdef SQLITE_ENABLE_STAT4
if( pNew->isPSample==0 ){
@ -651,12 +659,22 @@ static void samplePushPrevious(Stat4Accum *p, int iChng){
}
}
/* Update the anEq[] fields of any samples already collected. */
/* Check that no sample contains an anEq[] entry with an index of
** p->nMaxEqZero or greater set to zero. */
for(i=p->nSample-1; i>=0; i--){
int j;
for(j=iChng; j<p->nCol; j++){
if( p->a[i].anEq[j]==0 ) p->a[i].anEq[j] = p->current.anEq[j];
for(j=p->nMaxEqZero; j<p->nCol; j++) assert( p->a[i].anEq[j]>0 );
}
/* Update the anEq[] fields of any samples already collected. */
if( iChng<p->nMaxEqZero ){
for(i=p->nSample-1; i>=0; i--){
int j;
for(j=iChng; j<p->nCol; j++){
if( p->a[i].anEq[j]==0 ) p->a[i].anEq[j] = p->current.anEq[j];
}
}
p->nMaxEqZero = iChng;
}
#endif