1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-08 03:22:21 +03:00

Change the SQLITE_SCANSTAT_EST parameter so that it returns a double for

the estimated number of output rows per loop, rather than a 64-bit integer.
Revise the output format for the ".scanstats on" in the shell to make use
of this new capability.

FossilOrigin-Name: f9684000665ae7ef6f89c3773612b8286b8f545a
This commit is contained in:
drh
2014-11-06 03:55:10 +00:00
parent e1db0db899
commit 518140ed04
11 changed files with 85 additions and 76 deletions

View File

@@ -1195,21 +1195,24 @@ static void display_scanstats(
){
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
int i;
double rEstLoop = 1.0;
fprintf(pArg->out, "-------- scanstats --------\n");
for(i=0; 1; i++){
sqlite3_stmt *p = pArg->pStmt;
sqlite3_int64 nEst, nLoop, nVisit;
sqlite3_int64 nLoop, nVisit;
double rEst;
const char *zExplain;
if( sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_NLOOP, (void*)&nLoop) ){
break;
}
sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_NVISIT, (void*)&nVisit);
sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_EST, (void*)&nEst);
sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_EST, (void*)&rEst);
sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_EXPLAIN, (void*)&zExplain);
fprintf(pArg->out, "Loop %d: \"%s\"\n", i, zExplain);
fprintf(pArg->out, " nLoop=%-8lld nVisit=%-8lld nEst=%-8lld\n",
nLoop, nVisit, nEst
fprintf(pArg->out, "Loop %2d: \"%s\"\n", i, zExplain);
rEstLoop *= rEst;
fprintf(pArg->out, " nLoop=%-8lld nRow=%-8lld estRow=%-8lld estRow/Loop=%-8g\n",
nLoop, nVisit, (sqlite3_int64)rEstLoop, rEst
);
}
#else