diff options
author | drh <> | 2023-09-15 16:15:33 +0000 |
---|---|---|
committer | drh <> | 2023-09-15 16:15:33 +0000 |
commit | 20220d4682c0d22a36ad5eb19a6a15f92b6a85c3 (patch) | |
tree | ed1892547aee09c91dbaf24a322022ba86bb5b04 /src | |
parent | 658096e12470ed69be9843aae6e4fd120a2c6cef (diff) | |
download | sqlite-20220d4682c0d22a36ad5eb19a6a15f92b6a85c3.tar.gz sqlite-20220d4682c0d22a36ad5eb19a6a15f92b6a85c3.zip |
Experimental: Assume that a DISTINCT clause on a subquery reduces the number
of rows returned by that subquery by a factor of 8.
FossilOrigin-Name: 5a940e47d501f23347eaf084f4820e064e93665d19c8938c80715b71006ede8b
Diffstat (limited to 'src')
-rw-r--r-- | src/where.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/where.c b/src/where.c index 1d8ba88ba..79ec7f690 100644 --- a/src/where.c +++ b/src/where.c @@ -5353,6 +5353,15 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ pWInfo->nRowOut = pFrom->nRow; + /* TUNING: Assume that a DISTINCT clause on a subquery reduces + ** the output size by a factor of 8 (LogEst -30) + */ + if( (pWInfo->wctrlFlags & WHERE_WANT_DISTINCT)!=0 + && pWInfo->nRowOut>30 + ){ + pWInfo->nRowOut -= 30; + } + /* Free temporary memory and return success */ sqlite3StackFreeNN(pParse->db, pSpace); return SQLITE_OK; |