aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/select.c6
-rw-r--r--src/where.c3
2 files changed, 8 insertions, 1 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);
diff --git a/src/where.c b/src/where.c
index ed6320349..3320f6855 100644
--- a/src/where.c
+++ b/src/where.c
@@ -6934,7 +6934,8 @@ WhereInfo *sqlite3WhereBegin(
}
/* TUNING: Assume that a DISTINCT clause on a subquery reduces
- ** the output size by a factor of 8 (LogEst -30).
+ ** the output size by a factor of 8 (LogEst -30). Search for
+ ** tag-20250414a to see other cases.
*/
if( (pWInfo->wctrlFlags & WHERE_WANT_DISTINCT)!=0 ){
WHERETRACE(0x0080,("nRowOut reduced from %d to %d due to DISTINCT\n",