SQLite Forum

Timeline
Login

2 forum posts by user sqliteFan

2020-09-23
05:49 Edit reply: Welcome (artifact: 3e09a9340e user: sqliteFan)
Hello, Richard Hipp, about ANALYZE, I have a question, why can't call sqlite3BtreeRowCountEst() for tables with only rowid without other indexes?
I think invoking sqlite3BtreeRowCountEst() increases efficiency for large table.
See code comments:
static void analyzeOneTable(){
...
    for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
        ...
        addrRewind = sqlite3VdbeAddOp1(v, OP_Rewind, iIdxCur);
        VdbeCoverage(v);
        sqlite3VdbeAddOp3(v, OP_Count, iIdxCur, regTemp, 1); //will call sqlite3BtreeRowCountEst()
    }
    ...
    if( pOnlyIdx==0 && needTableCnt ){
        ...
        VdbeComment((v, "%s", pTab->zName));
        sqlite3VdbeAddOp2(v, OP_Count, iTabCur, regStat1); //will call sqlite3BtreeCount()
        jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, regStat1); VdbeCoverage(v)
    }
}
03:23 Reply: Welcome (artifact: 9a48ff1bcd user: sqliteFan)
Hello, Richard Hipp, about ANALYZE, I have a question, why can't call sqlite3BtreeRowCountEst() for tables with only rowid without other indexes?
I think invoking sqlite3BtreeRowCountEst () increases efficiency for large table.
See code comments:
static void analyzeOneTable(){
...
    for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
        ...
        addrRewind = sqlite3VdbeAddOp1(v, OP_Rewind, iIdxCur);
        VdbeCoverage(v);
        sqlite3VdbeAddOp3(v, OP_Count, iIdxCur, regTemp, 1); //will call sqlite3BtreeRowCountEst()
    }
    ...
    if( pOnlyIdx==0 && needTableCnt ){
        ...
        VdbeComment((v, "%s", pTab->zName));
        sqlite3VdbeAddOp2(v, OP_Count, iTabCur, regStat1); //will call sqlite3BtreeCount()
        jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, regStat1); VdbeCoverage(v)
    }
}