aboutsummaryrefslogtreecommitdiff
path: root/src/where.c
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2022-09-06 09:59:06 +0000
committerstephan <stephan@noemail.net>2022-09-06 09:59:06 +0000
commitae1ed83831d9cb6026a15d30d43a309bf3fd758f (patch)
treea8a255cd018524d40505172732ae7f0a8a92f930 /src/where.c
parent49cb8d7314f201bcc264ab3c38c01ae48822a7a4 (diff)
parent2e440a0801ad366d48532890b506853c0e34030e (diff)
downloadsqlite-ae1ed83831d9cb6026a15d30d43a309bf3fd758f.tar.gz
sqlite-ae1ed83831d9cb6026a15d30d43a309bf3fd758f.zip
Merge trunk into fiddle-opfs branch.
FossilOrigin-Name: 7f76eaec793720db87415a476ddf539bc4dea3e74c8e5406d6739206aebdacc2
Diffstat (limited to 'src/where.c')
-rw-r--r--src/where.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/where.c b/src/where.c
index 0a6f5e627..3e90fa9a7 100644
--- a/src/where.c
+++ b/src/where.c
@@ -3463,6 +3463,9 @@ static int whereLoopAddBtree(
#else
pNew->rRun = rSize + 16;
#endif
+ if( IsView(pTab) || (pTab->tabFlags & TF_Ephemeral)!=0 ){
+ pNew->wsFlags |= WHERE_VIEWSCAN;
+ }
ApplyCostMultiplier(pNew->rRun, pTab->costMult);
whereLoopOutputAdjust(pWC, pNew, rSize);
rc = whereLoopInsert(pBuilder, pNew);
@@ -4843,6 +4846,13 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
rUnsorted -= 2; /* TUNING: Slight bias in favor of no-sort plans */
}
+ /* TUNING: A full-scan of a VIEW or subquery in the outer loop
+ ** is not so bad. */
+ if( iLoop==0 && (pWLoop->wsFlags & WHERE_VIEWSCAN)!=0 ){
+ rCost += -10;
+ nOut += -30;
+ }
+
/* Check to see if pWLoop should be added to the set of
** mxChoice best-so-far paths.
**