/ 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 Unified Diffs Ignore Whitespace Patch

Changes to src/where.c.

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







<
|
<
<







4525
4526
4527
4528
4529
4530
4531

4532


4533
4534
4535
4536
4537
4538
4539
   && !pSrc->isRecursive
  ){
    /* Generate auto-index WhereLoops */
    WhereTerm *pTerm;
    WhereTerm *pWCEnd = pWC->a + pWC->nTerm;
    for(pTerm=pWC->a; rc==SQLITE_OK && pTerm<pWCEnd; pTerm++){
      if( pTerm->prereqRight & pNew->maskSelf ) continue;

      if( sqlite3ExprIsConstant(pTerm->pExpr->pRight) ) continue;


      if( termCanDriveIndex(pTerm, pSrc, 0) ){
        pNew->u.btree.nEq = 1;
        pNew->u.btree.nSkip = 0;
        pNew->u.btree.pIndex = 0;
        pNew->nLTerm = 1;
        pNew->aLTerm[0] = pTerm;
        /* TUNING: One-time cost for computing the automatic index is