Continue refining the NGQP

FossilOrigin-Name: 40567fddd468d00295275af8df09a7a1785e684a
This commit is contained in:
drh
2013-06-12 03:48:41 +00:00
parent 4f402f26b1
commit e217efc822
3 changed files with 18 additions and 18 deletions
+6 -6
View File
@@ -1,5 +1,5 @@
C Improved\sprocessing\sof\sDISTINCT.
D 2013-06-11T18:59:38.240
C Continue\srefining\sthe\sNGQP
D 2013-06-12T03:48:41.127
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -289,7 +289,7 @@ F src/vtab.c b05e5f1f4902461ba9f5fc49bb7eb7c3a0741a83
F src/wal.c 436bfceb141b9423c45119e68e444358ee0ed35d
F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
F src/walker.c 4fa43583d0a84b48f93b1e88f11adf2065be4e73
F src/where.c 2afa8f1a71dd088b137a7772f5c5dfee70c8fbe8
F src/where.c 3f38f769ef1365d7c8ff5b0ae9341b32f49bf46e
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
F test/aggnested.test 45c0201e28045ad38a530b5a144b73cd4aa2cfd6
@@ -1095,7 +1095,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
F tool/wherecosttest.c 4d0393bdbe7230adb712e925863744dd2b7ffc5b
F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
P f1cac24f06b9c71cfa472fdcf2da4cd8689a7cc3
R f41c25fe4af487f857bb0cfd93c46d44
P ba897100fed291d2025f68d09334f9985312298b
R 5ed376a4396f55c99b307b2ce75a8d86
U drh
Z 15fc6bc86393280f1819e7074b4ff66c
Z 47a7a33cc642ca844caf03a37d1ebaba
+1 -1
View File
@@ -1 +1 @@
ba897100fed291d2025f68d09334f9985312298b
40567fddd468d00295275af8df09a7a1785e684a
+11 -11
View File
@@ -74,7 +74,7 @@ struct WhereLevel {
int addrNxt; /* Jump here to start the next IN combination */
int addrCont; /* Jump here to continue with the next loop cycle */
int addrFirst; /* First instruction of interior of the loop */
u8 iFrom; /* FIXME: Which entry in the FROM clause */
u8 iFrom; /* Which entry in the FROM clause */
u8 op, p5; /* Opcode and P5 of the opcode that ends the loop */
int p1, p2; /* Operands of the opcode used to ends the loop */
union { /* Information that depends on plan.wsFlags */
@@ -4248,7 +4248,7 @@ static int whereLoopAddBtreeIndex(
pNew->wsFlags |= WHERE_COLUMN_IN;
if( ExprHasProperty(pExpr, EP_xIsSelect) ){
/* "x IN (SELECT ...)": Assume the SELECT returns 25 rows */
nIn = 46; /* whereCostFromInt(25) */
nIn = 46; assert( 46==whereCostFromInt(25) );
}else if( ALWAYS(pExpr->x.pList && pExpr->x.pList->nExpr) ){
/* "x IN (value, value, ...)" */
nIn = whereCostFromInt(pExpr->x.pList->nExpr);
@@ -4272,7 +4272,7 @@ static int whereLoopAddBtreeIndex(
}else if( pTerm->eOperator & (WO_ISNULL) ){
pNew->wsFlags |= WHERE_COLUMN_NULL;
pNew->u.btree.nEq++;
nIn = 10; /* Assume IS NULL matches two rows */
nIn = 10; assert( 10==whereCostFromInt(2) );
pNew->nOut = nRowEst + nInMul + nIn;
}else if( pTerm->eOperator & (WO_GT|WO_GE) ){
pNew->wsFlags |= WHERE_COLUMN_RANGE|WHERE_BTM_LIMIT;
@@ -4303,15 +4303,13 @@ static int whereLoopAddBtreeIndex(
pNew->nOut = whereCostFromInt(nOut);
}
#endif
if( pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK) ){
/* Step cost for each output row */
pNew->rRun = whereCostAdd(pNew->rRun, pNew->nOut);
}else{
if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){
/* Each row involves a step of the index, then a binary search of
** the main table */
WhereCost rStepAndSearch = whereCostAdd(10, rLogSize>17 ? rLogSize-17 : 1);
pNew->rRun = whereCostAdd(pNew->rRun, rStepAndSearch);
pNew->rRun = whereCostAdd(pNew->rRun, rLogSize>27 ? rLogSize-17 : 10);
}
/* Step cost for each output row */
pNew->rRun = whereCostAdd(pNew->rRun, pNew->nOut);
/* TBD: Adjust nOut for additional constraints */
rc = whereLoopInsert(pBuilder, pNew);
if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0
@@ -5251,7 +5249,7 @@ static int wherePathSolver(WhereInfo *pWInfo, WhereCost nRowEst){
for(iLoop=0; iLoop<nLoop; iLoop++){
WhereLevel *pLevel = pWInfo->a + iLoop;
pLevel->pWLoop = pWLoop = pFrom->aLoop[iLoop];
pLevel->iFrom = pWLoop->iTab; /* FIXME: Omit the iFrom field */
pLevel->iFrom = pWLoop->iTab;
pLevel->iTabCur = pWInfo->pTabList->a[pLevel->iFrom].iCursor;
}
if( (pWInfo->wctrlFlags & WHERE_DISTINCTBY)==0
@@ -5572,12 +5570,14 @@ WhereInfo *sqlite3WhereBegin(
** expressions, then we won't be able to satisfy it using indices, so
** go ahead and disable it now.
*/
if( pOrderBy ){
if( pOrderBy && pDistinct ){
for(ii=0; ii<pOrderBy->nExpr; ii++){
Expr *pExpr = sqlite3ExprSkipCollate(pOrderBy->a[ii].pExpr);
if( pExpr->op!=TK_COLUMN ){
pWInfo->pOrderBy = pOrderBy = 0;
break;
}else if( pExpr->iColumn<0 ){
break;
}
}
}