/ Check-in [3bc43594]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Add a comment explaining why WhereLoop cost adjustments are omitted for skip-scan loops.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3bc43594aaeee9225c0590677fcce480bedcb37b
User & Date: drh 2014-05-02 00:09:40
Context
2014-05-02
14:54
Fix a broken test case in fuzz.test. check-in: faa46935 user: dan tags: trunk
13:09
Merge latest trunk enhancements and fixes into the orderby-planning branch. check-in: 84862d3a user: drh tags: orderby-planning
00:09
Add a comment explaining why WhereLoop cost adjustments are omitted for skip-scan loops. check-in: 3bc43594 user: drh tags: trunk
2014-05-01
20:26
Fix an obscure problem to do with temp register allocation that could occur if more than one simple SELECT within a compound SELECT uses a partial sort. check-in: 427409ae user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/where.c.

  3779   3779   **
  3780   3780   **   (2) pTemplate costs more than any other WhereLoops for which pTemplate
  3781   3781   **       is a proper subset.
  3782   3782   **
  3783   3783   ** To say "WhereLoop X is a proper subset of Y" means that X uses fewer
  3784   3784   ** WHERE clause terms than Y and that every WHERE clause term used by X is
  3785   3785   ** also used by Y.
         3786  +**
         3787  +** This adjustment is omitted for SKIPSCAN loops.  In a SKIPSCAN loop, the
         3788  +** WhereLoop.nLTerm field is not an accurate measure of the number of WHERE
         3789  +** clause terms covered, since some of the first nLTerm entries in aLTerm[]
         3790  +** will be NULL (because they are skipped).  That makes it more difficult
         3791  +** to compare the loops.  We could add extra code to do the comparison, and
         3792  +** perhaps we will someday.  But SKIPSCAN is sufficiently uncommon, and this
         3793  +** adjustment is sufficient minor, that it is very difficult to construct
         3794  +** a test case where the extra code would improve the query plan.  Better
         3795  +** to avoid the added complexity and just omit cost adjustments to SKIPSCAN
         3796  +** loops.
  3786   3797   */
  3787   3798   static void whereLoopAdjustCost(const WhereLoop *p, WhereLoop *pTemplate){
  3788   3799     if( (pTemplate->wsFlags & WHERE_INDEXED)==0 ) return;
  3789   3800     if( (pTemplate->wsFlags & WHERE_SKIPSCAN)!=0 ) return;
  3790   3801     for(; p; p=p->pNextLoop){
  3791   3802       if( p->iTab!=pTemplate->iTab ) continue;
  3792   3803       if( (p->wsFlags & WHERE_INDEXED)==0 ) continue;