SQLite

Check-in [d8daaba7da]
Login

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
Timelines: family | ancestors | index-shape-1
Files: files | file ages | folders
SHA1: d8daaba7dae53c76858ff7d7de695af4763d9b1f
User & Date: drh 2013-09-02 23:40:47.395
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: d8daaba7da 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: f7079b5365 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/build.c.
2952
2953
2954
2955
2956
2957
2958


2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969

















2970
2971
2972
2973
2974
2975
2976
** how aiRowEst[] should be initialized.  The numbers generated here
** are based on typical values found in actual indices.
*/
void sqlite3DefaultRowEst(Index *pIdx){
  tRowcnt *a = pIdx->aiRowEst;
  int i;
  tRowcnt n;


  assert( a!=0 );
  a[0] = pIdx->pTable->nRowEst;
  if( a[0]<10 ) a[0] = 10;
  n = 10;
  for(i=1; i<=pIdx->nColumn; i++){
    a[i] = n;
    if( n>5 ) n--;
  }
  if( pIdx->onError!=OE_None ){
    a[pIdx->nColumn] = 1;
  }

















}

/*
** This routine will drop an existing named index.  This routine
** implements the DROP INDEX statement.
*/
void sqlite3DropIndex(Parse *pParse, SrcList *pName, int ifExists){







>
>











>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
** how aiRowEst[] should be initialized.  The numbers generated here
** are based on typical values found in actual indices.
*/
void sqlite3DefaultRowEst(Index *pIdx){
  tRowcnt *a = pIdx->aiRowEst;
  int i;
  tRowcnt n;

#if !defined(SQLITE_DEFAULT_INDEX_SHAPE) || SQLITE_DEFAULT_INDEX_SHAPE==0
  assert( a!=0 );
  a[0] = pIdx->pTable->nRowEst;
  if( a[0]<10 ) a[0] = 10;
  n = 10;
  for(i=1; i<=pIdx->nColumn; i++){
    a[i] = n;
    if( n>5 ) n--;
  }
  if( pIdx->onError!=OE_None ){
    a[pIdx->nColumn] = 1;
  }
#else /* if SQLITE_DEFAULT_INDEX_SHAPE==1 */
  tRowcnt x = 1, nMax = pIdx->pTable->nRowEst;
  int iLog;
  int isUnique = pIdx->onError!=OE_None;
  assert( a!=0 );
  a[0] = nMax;
  n = isUnique ? 1 : 10;
  for(iLog=1; n<nMax; iLog++, n<<=1){}
  i = pIdx->nColumn;
  x <<= iLog/i;
  //if( x>10 ) x = 10;
  a[i] = n = isUnique ? 1 : 10;
  while( i>1 ){
    n *= x;
    a[--i] = n;
  }
#endif
}

/*
** This routine will drop an existing named index.  This routine
** implements the DROP INDEX statement.
*/
void sqlite3DropIndex(Parse *pParse, SrcList *pName, int ifExists){