/ Check-in [97e5c70f]
Login

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

Overview
Comment:Improved optimization of ORDER BY.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | orderby-fix
Files: files | file ages | folders
SHA1:97e5c70f2f19a1bca70dd2221b757b9e5418fce0
User & Date: drh 2013-03-27 16:05:30
Context
2013-03-27
16:42
Restore additional ORDER BY optimizations that where broken by the recent ORDER BY fix. Closed-Leaf check-in: c77ee6e2 user: drh tags: orderby-fix
16:05
Improved optimization of ORDER BY. check-in: 97e5c70f user: drh tags: orderby-fix
15:04
A fix and test-case for the ORDER BY problem identified by ticket [a179fe7465]. This change causes sorting to occur in some cases where it is not strictly necessary. Further work is needed to avoid those extra sorts. check-in: 488089e6 user: drh tags: orderby-fix
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/where.c.

  3482   3482       ** on one page and hence more pages have to be fetched.
  3483   3483       **
  3484   3484       ** The ANALYZE command and the sqlite_stat1 and sqlite_stat3 tables do
  3485   3485       ** not give us data on the relative sizes of table and index records.
  3486   3486       ** So this computation assumes table records are about twice as big
  3487   3487       ** as index records
  3488   3488       */
  3489         -    if( (pc.plan.wsFlags&~(WHERE_REVERSE|WHERE_ORDERED))==WHERE_IDX_ONLY
         3489  +    if( (pc.plan.wsFlags&~(WHERE_REVERSE|WHERE_ORDERED|WHERE_OB_UNIQUE))
         3490  +                                                              ==WHERE_IDX_ONLY
  3490   3491        && (pWC->wctrlFlags & WHERE_ONEPASS_DESIRED)==0
  3491   3492        && sqlite3GlobalConfig.bUseCis
  3492   3493        && OptimizationEnabled(pParse->db, SQLITE_CoverIdxScan)
  3493   3494       ){
  3494   3495         /* This index is not useful for indexing, but it is a covering index.
  3495   3496         ** A full-scan of the index might be a little faster than a full-scan
  3496   3497         ** of the table, so give this case a cost slightly less than a table