diff options
author | drh <drh@noemail.net> | 2020-05-08 18:22:00 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2020-05-08 18:22:00 +0000 |
commit | 98aa1d735eb80f90b4523f50c17fc965ce967c79 (patch) | |
tree | 70e3e434fe26e0646099954c67eba2f0d6ea1e41 /src/select.c | |
parent | 91d4c374e208b73a97c01c5ba0d77aae910f4a26 (diff) | |
download | sqlite-98aa1d735eb80f90b4523f50c17fc965ce967c79.tar.gz sqlite-98aa1d735eb80f90b4523f50c17fc965ce967c79.zip |
Fix the count-optimization so that it honors the NOT INDEXED clause.
FossilOrigin-Name: 0d23a0b209900f4d7c6c13f75d4364f19afc23db72f9cfdb11e05b81502e8040
Diffstat (limited to 'src/select.c')
-rw-r--r-- | src/select.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/select.c b/src/select.c index d3b35377b..869984ff4 100644 --- a/src/select.c +++ b/src/select.c @@ -6698,13 +6698,15 @@ int sqlite3Select( ** passed to keep OP_OpenRead happy. */ if( !HasRowid(pTab) ) pBest = sqlite3PrimaryKeyIndex(pTab); - for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ - if( pIdx->bUnordered==0 - && pIdx->szIdxRow<pTab->szTabRow - && pIdx->pPartIdxWhere==0 - && (!pBest || pIdx->szIdxRow<pBest->szIdxRow) - ){ - pBest = pIdx; + if( !p->pSrc->a[0].fg.notIndexed ){ + for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ + if( pIdx->bUnordered==0 + && pIdx->szIdxRow<pTab->szTabRow + && pIdx->pPartIdxWhere==0 + && (!pBest || pIdx->szIdxRow<pBest->szIdxRow) + ){ + pBest = pIdx; + } } } if( pBest ){ |