/ Check-in [d8daaba7]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Add the experimental SQLITE_DEFAULT_INDEX_SHAPE=1 compile-time option that makes a much more pessimistic guess at the effectiveness of unanalyzed indices.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | index-shape-1
Files: files | file ages | folders
SHA1: d8daaba7dae53c76858ff7d7de695af4763d9b1f
User & Date: drh 2013-09-02 23:40:47
Context
2013-09-02
23:40
Add the experimental SQLITE_DEFAULT_INDEX_SHAPE=1 compile-time option that makes a much more pessimistic guess at the effectiveness of unanalyzed indices. Leaf check-in: d8daaba7 user: drh tags: index-shape-1
20:22
Simplify branch coverage testing by interchanging the order of two tests in the whereLoopInsert() function. check-in: f7079b53 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/build.c.

  2952   2952   ** how aiRowEst[] should be initialized.  The numbers generated here
  2953   2953   ** are based on typical values found in actual indices.
  2954   2954   */
  2955   2955   void sqlite3DefaultRowEst(Index *pIdx){
  2956   2956     tRowcnt *a = pIdx->aiRowEst;
  2957   2957     int i;
  2958   2958     tRowcnt n;
         2959  +
         2960  +#if !defined(SQLITE_DEFAULT_INDEX_SHAPE) || SQLITE_DEFAULT_INDEX_SHAPE==0
  2959   2961     assert( a!=0 );
  2960   2962     a[0] = pIdx->pTable->nRowEst;
  2961   2963     if( a[0]<10 ) a[0] = 10;
  2962   2964     n = 10;
  2963   2965     for(i=1; i<=pIdx->nColumn; i++){
  2964   2966       a[i] = n;
  2965   2967       if( n>5 ) n--;
  2966   2968     }
  2967   2969     if( pIdx->onError!=OE_None ){
  2968   2970       a[pIdx->nColumn] = 1;
  2969   2971     }
         2972  +#else /* if SQLITE_DEFAULT_INDEX_SHAPE==1 */
         2973  +  tRowcnt x = 1, nMax = pIdx->pTable->nRowEst;
         2974  +  int iLog;
         2975  +  int isUnique = pIdx->onError!=OE_None;
         2976  +  assert( a!=0 );
         2977  +  a[0] = nMax;
         2978  +  n = isUnique ? 1 : 10;
         2979  +  for(iLog=1; n<nMax; iLog++, n<<=1){}
         2980  +  i = pIdx->nColumn;
         2981  +  x <<= iLog/i;
         2982  +  //if( x>10 ) x = 10;
         2983  +  a[i] = n = isUnique ? 1 : 10;
         2984  +  while( i>1 ){
         2985  +    n *= x;
         2986  +    a[--i] = n;
         2987  +  }
         2988  +#endif
  2970   2989   }
  2971   2990   
  2972   2991   /*
  2973   2992   ** This routine will drop an existing named index.  This routine
  2974   2993   ** implements the DROP INDEX statement.
  2975   2994   */
  2976   2995   void sqlite3DropIndex(Parse *pParse, SrcList *pName, int ifExists){