diff options
author | drh <> | 2025-04-14 19:43:30 +0000 |
---|---|---|
committer | drh <> | 2025-04-14 19:43:30 +0000 |
commit | 483e1181c5a1e3f62d24161bcad34a6d8fb797fe (patch) | |
tree | 857828db9d5d1c5a896743084e6bdf43adcec665 /src/select.c | |
parent | c801f8954e8d5f61585fee3de472b2b259444150 (diff) | |
download | sqlite-483e1181c5a1e3f62d24161bcad34a6d8fb797fe.tar.gz sqlite-483e1181c5a1e3f62d24161bcad34a6d8fb797fe.zip |
Improved estimate on the number of output rows in a recursive common table expression
that uses the UNION operator. Follow-up to [f911f1c4977fbcae] and it's output row
estimate changes associated with DISTINCT queries.
FossilOrigin-Name: 92513f6bce7ecc778e78af3a77bc66ff65585fffa2e3138f8acb9e617121eeb0
Diffstat (limited to 'src/select.c')
-rw-r--r-- | src/select.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/select.c b/src/select.c index 91690c327..6e8ee58bc 100644 --- a/src/select.c +++ b/src/select.c @@ -8119,6 +8119,12 @@ int sqlite3Select( if( pWInfo==0 ) goto select_end; if( sqlite3WhereOutputRowCount(pWInfo) < p->nSelectRow ){ p->nSelectRow = sqlite3WhereOutputRowCount(pWInfo); + if( pDest->eDest<=SRT_DistQueue && pDest->eDest>=SRT_DistFifo ){ + /* TUNING: For a UNION CTE, because UNION is implies DISTINCT, + ** reduce the estimated output row count by 8 (LogEst 30). + ** Search for tag-20250414a to see other cases */ + p->nSelectRow -= 30; + } } if( sDistinct.isTnct && sqlite3WhereIsDistinct(pWInfo) ){ sDistinct.eTnctType = sqlite3WhereIsDistinct(pWInfo); |