SQLite

Check-in [76152ad2]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Do not use the viewscan optimization on a query that has only a single loop, as the cost adjustments can cause problems for outer queries. Proposed fix for the performance regression reported by forum post 64d36440e473516c.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 76152ad2ffe56034f2fd93d9a1ce9358e1677a7e9cd3dcd9f3a34a5c956a463e
User & Date: drh 2023-07-18 21:06:19
Context
2023-07-19
09:52
Two minor improvements to sum(), one of which was inspired by forum post af5be98dbc. (check-in: a0d3e757 user: drh tags: trunk)
2023-07-18
21:06
Do not use the viewscan optimization on a query that has only a single loop, as the cost adjustments can cause problems for outer queries. Proposed fix for the performance regression reported by forum post 64d36440e473516c. (check-in: 76152ad2 user: drh tags: trunk)
20:41
Improved ".wheretrace" for the VIEWSCAN optimization. (check-in: 27057ea7 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/where.c.
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
        }else{
          rCost = rUnsorted;
          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;
          WHERETRACE(0x80,("VIEWSCAN cost reduction for %c\n",pWLoop->cId));
        }

        /* Check to see if pWLoop should be added to the set of
        ** mxChoice best-so-far paths.







|







5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
        }else{
          rCost = rUnsorted;
          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 && nLoop>1 ){
          rCost += -10;
          nOut += -30;
          WHERETRACE(0x80,("VIEWSCAN cost reduction for %c\n",pWLoop->cId));
        }

        /* Check to see if pWLoop should be added to the set of
        ** mxChoice best-so-far paths.