/ Check-in [24a2e9dd]
Login

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

Overview
Comment:Improvements to the ORDER BY suppressor in the NGQP.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | nextgen-query-plan-exp
Files: files | file ages | folders
SHA1: 24a2e9ddcecd3926817d77abbb75d068ee7140ad
User & Date: drh 2013-05-30 23:21:20
Context
2013-05-31
11:57
Fix the constructAutomaticIndex() routine so that it works with NGQP. check-in: 5e1e6139 user: drh tags: nextgen-query-plan-exp
2013-05-30
23:21
Improvements to the ORDER BY suppressor in the NGQP. check-in: 24a2e9dd user: drh tags: nextgen-query-plan-exp
22:27
Incremental check-in with various NGQP fixes. Many tests still fail. check-in: a51d8c92 user: drh tags: nextgen-query-plan-exp
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/where.c.

  4584   4584       }
  4585   4585       if( !isUnique && requireUnique ) return 0;
  4586   4586       requireUnique = !isUnique;
  4587   4587       iCur = pWInfo->pTabList->a[pLoop->iTab].iCursor;
  4588   4588       j = 0;
  4589   4589       revSet = rev = 0;
  4590   4590       for(j=0; j<=nColumn && nUsed<nOrderBy; j++, nUsed++){
         4591  +      int skipable;
  4591   4592         pOBExpr = sqlite3ExprSkipCollate(pOrderBy->a[nUsed].pExpr);
  4592   4593         assert( pOBExpr->op==TK_COLUMN );
  4593   4594         if( pOBExpr->iTable!=iCur ) break;
  4594   4595         if( isUnique ) continue;
  4595   4596         if( j<nColumn ){
  4596   4597           /* Normal index columns */
  4597   4598           iColumn = pIndex->aiColumn[j];
................................................................................
  4598   4599           revIdx = pIndex->aSortOrder[j];
  4599   4600           if( iColumn==pIndex->pTable->iPKey ) iColumn = -1;
  4600   4601         }else{
  4601   4602           /* The ROWID column at the end */
  4602   4603           iColumn = -1;
  4603   4604           revIdx = 0;
  4604   4605         }
         4606  +      skipable = j<pLoop->u.btree.nEq && pLoop->aTerm[j]->eOperator!=WO_IN;
  4605   4607         if( pOBExpr->iColumn!=iColumn ){
  4606         -        if( j<pLoop->u.btree.nEq ){ nUsed--; continue; }
         4608  +        if( skipable ){ nUsed--; continue; }
  4607   4609           return 0;
  4608   4610         }
  4609   4611         if( iColumn>=0 ){
  4610   4612           pColl = sqlite3ExprCollSeq(pWInfo->pParse, pOrderBy->a[nUsed].pExpr);
  4611   4613           if( !pColl ) pColl = db->pDfltColl;
  4612         -        if( sqlite3StrICmp(pColl->zName, pIndex->azColl[j])!=0 ) return 0;
         4614  +        if( sqlite3StrICmp(pColl->zName, pIndex->azColl[j])!=0 ){
         4615  +          return 0;
         4616  +        }
  4613   4617         }
  4614         -      if( revSet ){
  4615         -        if( (rev ^ revIdx)!=pOrderBy->a[nUsed].sortOrder ) return 0;
  4616         -      }else{
  4617         -        rev = revIdx ^ pOrderBy->a[nUsed].sortOrder;
  4618         -        revSet = 1;
         4618  +      if( !skipable ){
         4619  +        if( revSet ){
         4620  +          if( (rev ^ revIdx)!=pOrderBy->a[nUsed].sortOrder ) return 0;
         4621  +        }else{
         4622  +          rev = revIdx ^ pOrderBy->a[nUsed].sortOrder;
         4623  +          revSet = 1;
         4624  +        }
  4619   4625         }
  4620   4626       }
  4621   4627       if( rev ) revMask |= ((Bitmask)1)<<i;
  4622   4628     }
  4623   4629     if( nUsed==nOrderBy ){
  4624   4630       *pRevMask = revMask;
  4625   4631       return 1;