SQLite

Check-in [3e9ed1aea4]
Login

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

Overview
Comment:When an index completely covers a table, it can be used as a covering index even if columns past the 63rd column are indexed and accessed.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3e9ed1aea43e8ce2eb74bb845ea2c05b5882e36e
User & Date: drh 2016-02-24 17:18:51.683
Original Comment: When an index complete covers a table, it can be used as a covering index even if columns past the 63rd column are indexed and accessed.
References
2016-02-24
20:16
Extend [3e9ed1ae] so that covering indexes on WITHOUT ROWID tables are also identified. (check-in: e721975faa user: dan tags: trunk)
Context
2016-02-24
19:57
Change a char* to const char* in order to suppress some harmless compiler warnings. (check-in: 56f62e34ae user: drh tags: trunk)
17:18
When an index completely covers a table, it can be used as a covering index even if columns past the 63rd column are indexed and accessed. (check-in: 3e9ed1aea4 user: drh tags: trunk)
16:14
Fix a problem with handling identifiers that start with "x" if SQLITE_OMIT_BLOB_LITERAL is defined. (check-in: b65217c69c user: dan tags: trunk)
15:43
Identify indexes that completely cover their table. (Closed-Leaf check-in: 71d488b599 user: drh tags: covering-index)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/build.c.
3188
3189
3190
3191
3192
3193
3194











3195
3196
3197
3198
3199
3200
3201
        i++;
      }
    }
    assert( i==pIndex->nColumn );
  }else{
    pIndex->aiColumn[i] = XN_ROWID;
    pIndex->azColl[i] = sqlite3StrBINARY;











  }
  sqlite3DefaultRowEst(pIndex);
  if( pParse->pNewTable==0 ) estimateIndexWidth(pIndex);

  if( pTab==pParse->pNewTable ){
    /* This routine has been called to create an automatic index as a
    ** result of a PRIMARY KEY or UNIQUE clause on a column definition, or







>
>
>
>
>
>
>
>
>
>
>







3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
        i++;
      }
    }
    assert( i==pIndex->nColumn );
  }else{
    pIndex->aiColumn[i] = XN_ROWID;
    pIndex->azColl[i] = sqlite3StrBINARY;
    /* If this index contains every column of its table, then mark
    ** it as a covering index */
    if( pTblName!=0 && pIndex->nColumn>=pTab->nCol ){
      pIndex->isCovering = 1;
      for(j=0; j<pTab->nCol; j++){
        if( j==pTab->iPKey ) continue;
        if( sqlite3ColumnOfIndex(pIndex,j)>=0 ) continue;
        pIndex->isCovering = 0;
        break;
      }
    }
  }
  sqlite3DefaultRowEst(pIndex);
  if( pParse->pNewTable==0 ) estimateIndexWidth(pIndex);

  if( pTab==pParse->pNewTable ){
    /* This routine has been called to create an automatic index as a
    ** result of a PRIMARY KEY or UNIQUE clause on a column definition, or