/ Check-in [127a5b77]
Login

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

Overview
Comment:An improved method for avoiding the use of the STAT3 samples to compute the estimated number of outputs when the left-most index is equality constrained. This check-in undoes the previous fix and applies a new one.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 127a5b776d16e1e23c5b3d454f6aaea67f1ded3a
User & Date: drh 2013-08-01 17:21:26
References
2013-08-01
17:43
Add test case for the problem fixed by [127a5b776d]. check-in: 65816718 user: dan tags: trunk
Context
2013-08-01
17:43
Add test case for the problem fixed by [127a5b776d]. check-in: 65816718 user: dan tags: trunk
17:21
An improved method for avoiding the use of the STAT3 samples to compute the estimated number of outputs when the left-most index is equality constrained. This check-in undoes the previous fix and applies a new one. check-in: 127a5b77 user: drh tags: trunk
16:52
Avoid using left-most column STAT3 samples if the left-most column has an equality constrain and there are inequality constraints on the second column. check-in: 31b4e63b user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/where.c.

  4416   4416         /* Adjust nOut and rRun for STAT3 range values */
  4417   4417         WhereCost rDiv;
  4418   4418         whereRangeScanEst(pParse, pProbe, pNew->u.btree.nEq,
  4419   4419                           pBtm, pTop, &rDiv);
  4420   4420         pNew->nOut = saved_nOut>rDiv+10 ? saved_nOut - rDiv : 10;
  4421   4421       }
  4422   4422   #ifdef SQLITE_ENABLE_STAT3
  4423         -    if( pNew->u.btree.nEq==1 && pProbe->nSample && saved_nEq==0
         4423  +    if( pNew->u.btree.nEq==1 && pProbe->nSample
  4424   4424        &&  OptimizationEnabled(db, SQLITE_Stat3) ){
  4425   4425         tRowcnt nOut = 0;
  4426   4426         if( (pTerm->eOperator & (WO_EQ|WO_ISNULL))!=0 ){
  4427   4427           testcase( pTerm->eOperator & WO_EQ );
  4428   4428           testcase( pTerm->eOperator & WO_ISNULL );
  4429   4429           rc = whereEqualScanEst(pParse, pProbe, pTerm->pExpr->pRight, &nOut);
  4430   4430         }else if( (pTerm->eOperator & WO_IN)
  4431   4431                &&  !ExprHasProperty(pTerm->pExpr, EP_xIsSelect)  ){
  4432   4432           rc = whereInScanEst(pParse, pProbe, pTerm->pExpr->x.pList, &nOut);
  4433   4433         }
  4434         -      if( rc==SQLITE_OK ) pNew->nOut = whereCost(nOut);
         4434  +      assert( nOut==0 || rc==SQLITE_OK );
         4435  +      if( nOut ) pNew->nOut = whereCost(nOut);
  4435   4436       }
  4436   4437   #endif
  4437   4438       if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){
  4438   4439         /* Each row involves a step of the index, then a binary search of
  4439   4440         ** the main table */
  4440   4441         pNew->rRun =  whereCostAdd(pNew->rRun, rLogSize>27 ? rLogSize-17 : 10);
  4441   4442       }