Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Restore additional ORDER BY optimizations that where broken by the recent ORDER BY fix. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | orderby-fix |
Files: | files | file ages | folders |
SHA1: |
c77ee6e20d3a8c91a8bf4c9063c36a95 |
User & Date: | drh 2013-03-27 16:42:21.685 |
Context
2013-03-27
| ||
17:20 | In order to optimize out the ORDER BY clause, outer loops must generate values for ORDER BY terms that are unique or else the inner loops must generate no more than a single row. Fix for ticket [a179fe7465]. (check-in: 2936f7466e user: drh tags: trunk) | |
16:42 | Restore additional ORDER BY optimizations that where broken by the recent ORDER BY fix. (Closed-Leaf check-in: c77ee6e20d user: drh tags: orderby-fix) | |
16:05 | Improved optimization of ORDER BY. (check-in: 97e5c70f2f user: drh tags: orderby-fix) | |
Changes
Changes to src/where.c.
︙ | ︙ | |||
2923 2924 2925 2926 2927 2928 2929 2930 | int outerObUnique; /* Outer loops generate different values in ** every row for the ORDER BY columns */ if( p->i==0 ){ nPriorSat = 0; outerObUnique = 1; }else{ nPriorSat = p->aLevel[p->i-1].plan.nOBSat; | > | | > > | 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 | int outerObUnique; /* Outer loops generate different values in ** every row for the ORDER BY columns */ if( p->i==0 ){ nPriorSat = 0; outerObUnique = 1; }else{ u32 wsFlags = p->aLevel[p->i-1].plan.wsFlags; nPriorSat = p->aLevel[p->i-1].plan.nOBSat; if( (wsFlags & WHERE_ORDERED)==0 ){ /* This loop cannot be ordered unless the next outer loop is ** also ordered */ return nPriorSat; } if( OptimizationDisabled(db, SQLITE_OrderByIdxJoin) ){ /* Only look at the outer-most loop if the OrderByIdxJoin ** optimization is disabled */ return nPriorSat; } testcase( wsFlags & WHERE_OB_UNIQUE ); testcase( wsFlags & WHERE_ALL_UNIQUE ); outerObUnique = (wsFlags & (WHERE_OB_UNIQUE|WHERE_ALL_UNIQUE))!=0; } pOrderBy = p->pOrderBy; assert( pOrderBy!=0 ); if( pIdx->bUnordered ){ /* Hash indices (indicated by the "unordered" tag on sqlite_stat1) cannot ** be used for sorting */ return nPriorSat; |
︙ | ︙ |