diff options
author | dan <Dan Kennedy> | 2022-12-03 21:24:26 +0000 |
---|---|---|
committer | dan <Dan Kennedy> | 2022-12-03 21:24:26 +0000 |
commit | ad23a47acdc3258e988c91eac48eb8ce7a79fd53 (patch) | |
tree | 95da521aa81425b70f1234266e449a0351243b17 /src | |
parent | f6f01f15dd9ff495ac59f5abc3bbe15f4d8e88c8 (diff) | |
download | sqlite-ad23a47acdc3258e988c91eac48eb8ce7a79fd53.tar.gz sqlite-ad23a47acdc3258e988c91eac48eb8ce7a79fd53.zip |
Enhance SQLITE_SCANSTAT_NCYCLE so that it reports on virtual tables.
FossilOrigin-Name: 622d8eb3724bee617b55d6fb71f1a2d683db6858065adced6bf3ce9525bcd6b5
Diffstat (limited to 'src')
-rw-r--r-- | src/shell.c.in | 2 | ||||
-rw-r--r-- | src/vdbeapi.c | 28 | ||||
-rw-r--r-- | src/wherecode.c | 3 |
3 files changed, 26 insertions, 7 deletions
diff --git a/src/shell.c.in b/src/shell.c.in index 7cbd6b3c4..d3ef84e44 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -3054,7 +3054,7 @@ static void display_scanstats( zText = sqlite3_mprintf("%s", z); if( nCycle>=0 || nLoop>=0 || nRow>=0 ){ char *z = 0; - if( nCycle>=0 ){ + if( nCycle>=0 && nTotal>0 ){ z = sqlite3_mprintf("%zcycles=%lld [%d%%]", z, nCycle, ((nCycle*100)+nTotal/2) / nTotal ); diff --git a/src/vdbeapi.c b/src/vdbeapi.c index c00980d6b..2b9b1087f 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -2206,17 +2206,33 @@ int sqlite3_stmt_scanstatus_v2( break; } case SQLITE_SCANSTAT_NCYCLE: { - i64 res = -1; - if( pScan->aAddrRange[0] ){ + i64 res = 0; + if( pScan->aAddrRange[0]==0 ){ + res = -1; + }else{ int ii; - res = 0; for(ii=0; ii<ArraySize(pScan->aAddrRange); ii+=2){ int iIns = pScan->aAddrRange[ii]; int iEnd = pScan->aAddrRange[ii+1]; if( iIns==0 ) break; - while( iIns<=iEnd ){ - res += p->anCycle[iIns]; - iIns++; + if( iIns>0 ){ + while( iIns<=iEnd ){ + res += p->anCycle[iIns]; + iIns++; + } + }else{ + int iOp; + for(iOp=0; iOp<p->nOp; iOp++){ + Op *pOp = &p->aOp[iOp]; + if( pOp->p1!=iEnd ) continue; + if( pOp->opcode!=OP_VFilter && pOp->opcode!=OP_VColumn + && pOp->opcode!=OP_Rowid && pOp->opcode!=OP_VOpen + && pOp->opcode!=OP_VNext + ){ + continue; + } + res += p->anCycle[iOp]; + } } } } diff --git a/src/wherecode.c b/src/wherecode.c index b744556fa..54c79baf9 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -302,6 +302,9 @@ void sqlite3WhereAddScanStatus( sqlite3VdbeScanStatus( v, addrExplain, pLvl->addrBody, pLvl->addrVisit, pLoop->nOut, zObj ); + if( pLoop->wsFlags & WHERE_VIRTUALTABLE ){ + sqlite3VdbeScanStatusRange(v, addrExplain, -1, pLvl->iTabCur); + } } #endif |