/ Check-in [36d67e1d]
Login

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

Overview
Comment:Simplification to the logic that prevents automatic indexes from being formed on constant expressions.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | autoindex-improvements
Files: files | file ages | folders
SHA1: 36d67e1dd2b4f4c22d02f3c3b8d372074de5523a
User & Date: drh 2014-06-17 09:52:26
Context
2014-06-17
12:33
A different approach to the autoindex problem that deletes query-planner code rather than adding it. check-in: f270fb6e user: drh tags: autoindex-improvements
09:52
Simplification to the logic that prevents automatic indexes from being formed on constant expressions. check-in: 36d67e1d user: drh tags: autoindex-improvements
09:00
Allow an automatic index on a WHERE constraint where the RHS is does not reference another table as long as the RHS is not a constant. check-in: 58acc2a8 user: drh tags: autoindex-improvements
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/where.c.

  4525   4525      && !pSrc->isRecursive
  4526   4526     ){
  4527   4527       /* Generate auto-index WhereLoops */
  4528   4528       WhereTerm *pTerm;
  4529   4529       WhereTerm *pWCEnd = pWC->a + pWC->nTerm;
  4530   4530       for(pTerm=pWC->a; rc==SQLITE_OK && pTerm<pWCEnd; pTerm++){
  4531   4531         if( pTerm->prereqRight & pNew->maskSelf ) continue;
  4532         -      if( pTerm->prereqRight==0
  4533         -       && sqlite3ExprIsConstant(pTerm->pExpr->pRight) ){
  4534         -        continue;
  4535         -      }
         4532  +      if( sqlite3ExprIsConstant(pTerm->pExpr->pRight) ) continue;
  4536   4533         if( termCanDriveIndex(pTerm, pSrc, 0) ){
  4537   4534           pNew->u.btree.nEq = 1;
  4538   4535           pNew->u.btree.nSkip = 0;
  4539   4536           pNew->u.btree.pIndex = 0;
  4540   4537           pNew->nLTerm = 1;
  4541   4538           pNew->aLTerm[0] = pTerm;
  4542   4539           /* TUNING: One-time cost for computing the automatic index is