SQLite

Check-in [7473c4dfc1]
Login

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

Overview
Comment:Remove an unnecessary conditional.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | query-plan-experiments
Files: files | file ages | folders
SHA1: 7473c4dfc10a47594affa6f4e071a08dc8838c0c
User & Date: drh 2014-03-31 20:05:20.135
Context
2014-04-04
18:20
Merge changes to the query planner that strive to ensure that any index usage that is a proper subset of some other index usage always has a slightly higher cost. (check-in: 683dd379a2 user: drh tags: trunk)
2014-03-31
20:05
Remove an unnecessary conditional. (Closed-Leaf check-in: 7473c4dfc1 user: drh tags: query-plan-experiments)
19:49
Also make sure an index that is a proper subset of some other index has a higher cost than that other index. Add test cases. (check-in: b7830d232b user: drh tags: query-plan-experiments)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/where.c.
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727

/*
** Return TRUE if the set of WHERE clause terms used by pA is a proper
** subset of the WHERE clause terms used by pB.
*/
static int whereLoopProperSubset(const WhereLoop *pA, const WhereLoop *pB){
  int i, j;
  if( pA->nLTerm>=pB->nLTerm ) return 0;
  for(j=0, i=pA->nLTerm-1; i>=0 && j>=0; i--){
    for(j=pB->nLTerm-1; j>=0; j--){
      if( pB->aLTerm[j]==pA->aLTerm[i] ) break;
    }
  }
  return j>=0;
}







|







3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727

/*
** Return TRUE if the set of WHERE clause terms used by pA is a proper
** subset of the WHERE clause terms used by pB.
*/
static int whereLoopProperSubset(const WhereLoop *pA, const WhereLoop *pB){
  int i, j;
  assert( pA->nLTerm<pB->nLTerm );  /* Checked by calling function */
  for(j=0, i=pA->nLTerm-1; i>=0 && j>=0; i--){
    for(j=pB->nLTerm-1; j>=0; j--){
      if( pB->aLTerm[j]==pA->aLTerm[i] ) break;
    }
  }
  return j>=0;
}