SQLite4
Check-in [97c7b5580f]
Not logged in

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

Overview
Comment:Reenable the whereShortCut() optimization.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 97c7b5580f2d5f70fe3ad18c9bc7f28f61d6355e
User & Date: dan 2013-07-25 15:13:11
Context
2013-07-25
20:02
Partially reenable automatic indexes. Six legacy tests cases in autoindex1.test are still failing as of this commit. check-in: 2244abfac2 user: dan tags: trunk
15:13
Reenable the whereShortCut() optimization. check-in: 97c7b5580f user: dan tags: trunk
14:18
Update test file eval.test to account for caching in the RowDecoder. check-in: 3bbe9e80b8 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/where.c.

  5570   5570     WhereClause *pWC;
  5571   5571     WhereTerm *pTerm;
  5572   5572     WhereLoop *pLoop;
  5573   5573     int iCur;
  5574   5574     int j;
  5575   5575     Table *pTab;
  5576   5576     Index *pIdx;
  5577         -
  5578         -  return 0;
  5579   5577     
  5580   5578     pWInfo = pBuilder->pWInfo;
  5581   5579     if( pWInfo->wctrlFlags & WHERE_FORCE_TABLE ) return 0;
  5582   5580     assert( pWInfo->pTabList->nSrc>=1 );
  5583   5581     pItem = pWInfo->pTabList->a;
  5584   5582     pTab = pItem->pTab;
  5585   5583     if( IsVirtual(pTab) ) return 0;
  5586   5584     if( pItem->zIndex ) return 0;
  5587   5585     iCur = pItem->iCursor;
  5588   5586     pWC = &pWInfo->sWC;
  5589   5587     pLoop = pBuilder->pNew;
  5590   5588     pLoop->wsFlags = 0;
  5591         -  pTerm = findTerm(pWC, iCur, -1, 0, WO_EQ, 0);
  5592         -  if( pTerm ){
  5593         -    assert( 0 );
  5594         -    pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_IPK|WHERE_ONEROW;
  5595         -    pLoop->aLTerm[0] = pTerm;
  5596         -    pLoop->nLTerm = 1;
  5597         -    pLoop->u.btree.nEq = 1;
  5598         -    /* TUNING: Cost of a rowid lookup is 10 */
  5599         -    pLoop->rRun = 33;  /* 33==whereCost(10) */
  5600         -  }else{
  5601         -    for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
  5602         -      if( pIdx->onError==OE_None ) continue;
  5603         -      for(j=0; j<pIdx->nColumn; j++){
  5604         -        pTerm = findTerm(pWC, iCur, pIdx->aiColumn[j], 0, WO_EQ, pIdx);
  5605         -        if( pTerm==0 ) break;
  5606         -        whereLoopResize(pWInfo->pParse->db, pLoop, j);
  5607         -        pLoop->aLTerm[j] = pTerm;
  5608         -      }
  5609         -      if( j!=pIdx->nColumn ) continue;
  5610         -      pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_ONEROW|WHERE_INDEXED;
  5611         -      if( (pItem->colUsed & ~columnsInIndex(pIdx))==0 ){
  5612         -        pLoop->wsFlags |= WHERE_IDX_ONLY;
  5613         -      }
  5614         -      pLoop->nLTerm = j;
  5615         -      pLoop->u.btree.nEq = j;
  5616         -      pLoop->u.btree.pIndex = pIdx;
  5617         -      /* TUNING: Cost of a unique index lookup is 15 */
  5618         -      pLoop->rRun = 39;  /* 39==whereCost(15) */
  5619         -      break;
  5620         -    }
  5621         -  }
         5589  +
         5590  +  for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
         5591  +    if( pIdx->onError==OE_None ) continue;
         5592  +    for(j=0; j<pIdx->nColumn; j++){
         5593  +      pTerm = findTerm(pWC, iCur, pIdx->aiColumn[j], 0, WO_EQ, pIdx);
         5594  +      if( pTerm==0 ) break;
         5595  +      whereLoopResize(pWInfo->pParse->db, pLoop, j);
         5596  +      pLoop->aLTerm[j] = pTerm;
         5597  +    }
         5598  +    if( j!=pIdx->nColumn ) continue;
         5599  +    pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_ONEROW|WHERE_INDEXED;
         5600  +    if( (pItem->colUsed & ~columnsInIndex(pIdx))==0 ){
         5601  +      pLoop->wsFlags |= WHERE_IDX_ONLY;
         5602  +    }
         5603  +    pLoop->nLTerm = j;
         5604  +    pLoop->u.btree.nEq = j;
         5605  +    pLoop->u.btree.pIndex = pIdx;
         5606  +    /* TUNING: Cost of a unique index lookup is 15 */
         5607  +    pLoop->rRun = 39;  /* 39==whereCost(15) */
         5608  +    break;
         5609  +  }
         5610  +
  5622   5611     if( pLoop->wsFlags ){
  5623   5612       pLoop->nOut = (WhereCost)1;
  5624   5613       pWInfo->a[0].pWLoop = pLoop;
  5625   5614       pLoop->maskSelf = getMask(&pWInfo->sMaskSet, iCur);
  5626   5615       pWInfo->a[0].iTabCur = iCur;
  5627   5616       pWInfo->nRowOut = 1;
  5628   5617       if( pWInfo->pOrderBy ) pWInfo->bOBSat =  1;