SQLite

Check-in [30033f9650]
Login

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

Overview
Comment:Ugh. Consecutive UNIQUE index entries are only distinct if the index is on NOT NULL columns. So the previous version was not quite right. This check-in fixes the problem.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | faster-analyze
Files: files | file ages | folders
SHA1: 30033f965030a015fad15e532bcaba1314c8cc0f
User & Date: drh 2014-07-23 19:37:21.314
Context
2014-07-24
19:54
Avoid change tests when analyzing single-column unique indexes after getting past the initial NULL entries. (check-in: 4690e99c07 user: drh tags: faster-analyze)
2014-07-23
19:37
Ugh. Consecutive UNIQUE index entries are only distinct if the index is on NOT NULL columns. So the previous version was not quite right. This check-in fixes the problem. (check-in: 30033f9650 user: drh tags: faster-analyze)
18:36
Improve the performance of the ANALYZE command by taking advantage of the fact that every row of a UNIQUE index is distinct. (check-in: 3e1e79e133 user: drh tags: faster-analyze)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/analyze.c.
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
    if( !HasRowid(pTab) && IsPrimaryKeyIndex(pIdx) ){
      nCol = pIdx->nKeyCol;
      zIdxName = pTab->zName;
      nColTest = nCol - 1;
    }else{
      nCol = pIdx->nColumn;
      zIdxName = pIdx->zName;
      nColTest = pIdx->onError==OE_None ? nCol-1 : pIdx->nKeyCol-1;
    }
    aGotoChng = sqlite3DbMallocRaw(db, sizeof(int)*(nColTest+1));
    if( aGotoChng==0 ) continue;

    /* Populate the register containing the index name. */
    sqlite3VdbeAddOp4(v, OP_String8, 0, regIdxname, 0, zIdxName, 0);
    VdbeComment((v, "Analysis for %s.%s", pTab->zName, zIdxName));







|







1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
    if( !HasRowid(pTab) && IsPrimaryKeyIndex(pIdx) ){
      nCol = pIdx->nKeyCol;
      zIdxName = pTab->zName;
      nColTest = nCol - 1;
    }else{
      nCol = pIdx->nColumn;
      zIdxName = pIdx->zName;
      nColTest = pIdx->uniqNotNull ? pIdx->nKeyCol-1 : nCol-1;
    }
    aGotoChng = sqlite3DbMallocRaw(db, sizeof(int)*(nColTest+1));
    if( aGotoChng==0 ) continue;

    /* Populate the register containing the index name. */
    sqlite3VdbeAddOp4(v, OP_String8, 0, regIdxname, 0, zIdxName, 0);
    VdbeComment((v, "Analysis for %s.%s", pTab->zName, zIdxName));