SQLite

Check-in [3d0609c958]
Login

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

Overview
Comment:Fix an over-aggressive optimization of ORDER BY on a three-way join where the second table is UNIQUE and the ORDER BY occurs on the third table. Ticket [c997b11c4d53a2ee].
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | branch-3.7.15
Files: files | file ages | folders
SHA1: 3d0609c958040d049b86f69d750ffcef764417df
User & Date: drh 2013-01-09 11:44:20.158
Original Comment: Fix an over-aggressive optimization of ORDER BY on a three-way join where the second table is UNIQUE and the ORDER BY occurs on the third table. Ticket [598f5f7596b0557].
Context
2013-01-09
11:53
Version 3.7.15.2 (check-in: c0e09560d2 user: drh tags: version-3.7.15.2, branch-3.7.15)
11:44
Fix an over-aggressive optimization of ORDER BY on a three-way join where the second table is UNIQUE and the ORDER BY occurs on the third table. Ticket [c997b11c4d53a2ee]. (check-in: 3d0609c958 user: drh tags: branch-3.7.15)
2012-12-19
20:39
Version 3.7.15.1 (check-in: 6b85b767d0 user: drh tags: release, version-3.7.15.1, branch-3.7.15)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/where.c.
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
    ** variable.  */
    if( bSort && (pSrc->jointype & JT_LEFT)==0 ){
      int bRev = 2;
      WHERETRACE(("      --> before isSortingIndex: nPriorSat=%d\n",nPriorSat));
      pc.plan.nOBSat = isSortingIndex(p, pProbe, iCur, &bRev);
      WHERETRACE(("      --> after  isSortingIndex: bRev=%d nOBSat=%d\n",
                  bRev, pc.plan.nOBSat));
      if( nPriorSat<pc.plan.nOBSat || (pc.plan.wsFlags & WHERE_UNIQUE)!=0 ){
        pc.plan.wsFlags |= WHERE_ORDERED;
      }
      if( nOrderBy==pc.plan.nOBSat ){
        bSort = 0;
        pc.plan.wsFlags |= WHERE_ROWID_RANGE|WHERE_COLUMN_RANGE;
      }
      if( bRev & 1 ) pc.plan.wsFlags |= WHERE_REVERSE;







|







3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
    ** variable.  */
    if( bSort && (pSrc->jointype & JT_LEFT)==0 ){
      int bRev = 2;
      WHERETRACE(("      --> before isSortingIndex: nPriorSat=%d\n",nPriorSat));
      pc.plan.nOBSat = isSortingIndex(p, pProbe, iCur, &bRev);
      WHERETRACE(("      --> after  isSortingIndex: bRev=%d nOBSat=%d\n",
                  bRev, pc.plan.nOBSat));
      if( nPriorSat<pc.plan.nOBSat || (pc.plan.wsFlags & WHERE_ALL_UNIQUE)!=0 ){
        pc.plan.wsFlags |= WHERE_ORDERED;
      }
      if( nOrderBy==pc.plan.nOBSat ){
        bSort = 0;
        pc.plan.wsFlags |= WHERE_ROWID_RANGE|WHERE_COLUMN_RANGE;
      }
      if( bRev & 1 ) pc.plan.wsFlags |= WHERE_REVERSE;