SQLite

Check-in [700a3c6944]
Login

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

Overview
Comment:Improved comments, including a typo fix, on the whereLoopCheaperProperSubset() function.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 700a3c694438ca6cca185d0097f24799e82717ef38cb47bd83666c80f0e3cb2f
User & Date: drh 2017-10-16 11:50:12.951
Context
2017-10-17
13:44
Fix the ".check" command of the command-line shell to return 1 (error) rather than 2 (exit) on a test failure. (check-in: e2af0cc6ef user: drh tags: trunk)
2017-10-16
11:50
Improved comments, including a typo fix, on the whereLoopCheaperProperSubset() function. (check-in: 700a3c6944 user: drh tags: trunk)
2017-10-15
22:16
In the query planner, do not consider index X to be a proper subset of index Y if X is a covering index but Y is not. (check-in: ee31c04353 user: drh tags: trunk)
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to src/where.c.
1881
1882
1883
1884
1885
1886
1887
1888

1889
1890
1891
1892
1893
1894
1895
1896
1897
1898



1899
1900
1901
1902
1903
1904
1905
1881
1882
1883
1884
1885
1886
1887

1888
1889
1890
1891
1892
1893
1894
1895
1896
1897

1898
1899
1900
1901
1902
1903
1904
1905
1906
1907







-
+









-
+
+
+







  }
}

/*
** Return TRUE if all of the following are true:
**
**   (1)  X has the same or lower cost that Y
**   (2)  X users fewer WHERE clause terms than Y
**   (2)  X uses fewer WHERE clause terms than Y
**   (3)  Every WHERE clause term used by X is also used by Y
**   (4)  X skips at least as many columns as Y
**   (5)  If X is a covering index, than Y is too
**
** Conditions (2) and (3) mean that X is a "proper subset" of Y.
** If X is a proper subset of Y then Y is a better choice and ought
** to have a lower cost.  This routine returns TRUE when that cost 
** relationship is inverted and needs to be adjusted.  Constraint (4)
** was added because if X uses skip-scan less than Y it still might
** deserve a lower cost even if it is a proper subset of Y.
** deserve a lower cost even if it is a proper subset of Y.  Constraint (5)
** was added because a covering index probably deserves to have a lower cost
** than a non-covering index even if it is a proper subset.
*/
static int whereLoopCheaperProperSubset(
  const WhereLoop *pX,       /* First WhereLoop to compare */
  const WhereLoop *pY        /* Compare against this WhereLoop */
){
  int i, j;
  if( pX->nLTerm-pX->nSkip >= pY->nLTerm-pY->nSkip ){