/ Check-in [efffc49b]
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:Do not try to use STAT2 to refine the row estimate of a query that uses a unique or nearly-unique index.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: efffc49baf38698ed3de05d16b4261bf405d42d7
User & Date: drh 2011-07-13 18:31:10
Context
2011-07-15
13:43
In os_unix.c, check if the ESTALE macro is defined before using it. check-in: 87017410 user: dan tags: trunk
2011-07-13
18:31
Do not try to use STAT2 to refine the row estimate of a query that uses a unique or nearly-unique index. check-in: efffc49b user: drh tags: trunk
16:03
Added the SQLITE_FCNTL_WIN32_AV_RETRY file control for configuring the retry counts and delays in the windows VFS. check-in: 7aaf0a6a user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/where.c.

  3107   3107       nRow = (double)(aiRowEst[nEq] * nInMul);
  3108   3108       if( bInEst && nRow*2>aiRowEst[0] ){
  3109   3109         nRow = aiRowEst[0]/2;
  3110   3110         nInMul = (int)(nRow / aiRowEst[nEq]);
  3111   3111       }
  3112   3112   
  3113   3113   #ifdef SQLITE_ENABLE_STAT2
  3114         -    /* If the constraint is of the form x=VALUE and histogram
         3114  +    /* If the constraint is of the form x=VALUE or x IN (E1,E2,...)
         3115  +    ** and we do not think that values of x are unique and if histogram
  3115   3116       ** data is available for column x, then it might be possible
  3116   3117       ** to get a better estimate on the number of rows based on
  3117   3118       ** VALUE and how common that value is according to the histogram.
  3118   3119       */
  3119         -    if( nRow>(double)1 && nEq==1 && pFirstTerm!=0 ){
         3120  +    if( nRow>(double)1 && nEq==1 && pFirstTerm!=0 && aiRowEst[1]>1 ){
  3120   3121         if( pFirstTerm->eOperator & (WO_EQ|WO_ISNULL) ){
  3121   3122           testcase( pFirstTerm->eOperator==WO_EQ );
  3122   3123           testcase( pFirstTerm->eOperator==WO_ISNULL );
  3123   3124           whereEqualScanEst(pParse, pProbe, pFirstTerm->pExpr->pRight, &nRow);
  3124   3125         }else if( pFirstTerm->eOperator==WO_IN && bInEst==0 ){
  3125   3126           whereInScanEst(pParse, pProbe, pFirstTerm->pExpr->x.pList, &nRow);
  3126   3127         }