/ Check-in [5774f217]
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 [c997b11c4d53a2].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5774f2175ce621dfc4b6b93f7ee13fd66f3ec2b9
User & Date: drh 2013-01-09 11:31:17
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
15:44
Check in an extra test for the fts4 "content=" option. No code changes. check-in: 0d0e5ab8 user: dan tags: trunk
14:49
Merge latest trunk changes into the sessions branch, especially the ORDER BY bug fix of 3.7.15.2. check-in: 34af6fac user: drh tags: sessions
11:31
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 [c997b11c4d53a2]. check-in: 5774f217 user: drh tags: trunk
11:27
Fix the date on the new orderby3.test test case. check-in: 7249bfc2 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/where.c.

3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
    ** 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;







|







3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
    ** 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;