An index might be useful for ORDER BY if any indexed column is in the

ORDER BY clause, not just the first indexed column.

FossilOrigin-Name: ade473b5ae3fe2162b0ec29731d8e864a9301e07
This commit is contained in:
drh 2013-06-13 17:58:08 +00:00
parent 53cfbe92d1
commit 6d38147c19
3 changed files with 11 additions and 12 deletions

View File

@ -1,5 +1,5 @@
C Make\ssure\sthat\sdisabling\sthe\scovering\sindex\sscan\soptimization\sdoes\snot\nprevent\sa\scovering\sindex\sfrom\sbeing\sused\sto\ssatisfy\san\sORDER\sBY\sclause.
D 2013-06-13T17:28:22.026
C An\sindex\smight\sbe\suseful\sfor\sORDER\sBY\sif\sany\sindexed\scolumn\sis\sin\sthe\nORDER\sBY\sclause,\snot\sjust\sthe\sfirst\sindexed\scolumn.
D 2013-06-13T17:58:08.642
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 700085a8d8e0edf13db11e110577320ec7348edc
F src/where.c ba5f6766cfc7fcee945d45120cbb6e39a881b8e0
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 f407dc4c79786982a475261866a161cd007947ae
F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
P 459a7b9068310b36fed950940d251c4b798ffc58
R 242dd2338fa025aa7191faa8afaf3ae6
P e8b7ea8202c443bfc8a978588c7d2cfaa14a8fea
R 20475a52b4ff0eaa6499f9e0ae4a1e9c
U drh
Z 7fc4ebaffcaa0d84212cec77e769d428
Z f8930bf04903145489a941260cbef3e2

View File

@ -1 +1 @@
e8b7ea8202c443bfc8a978588c7d2cfaa14a8fea
ade473b5ae3fe2162b0ec29731d8e864a9301e07

View File

@ -4370,18 +4370,17 @@ static int indexMightHelpWithOrderBy(
int iCursor
){
ExprList *pOB;
int iCol;
int ii;
int ii, jj;
if( pIndex->bUnordered ) return 0;
if( (pOB = pBuilder->pWInfo->pOrderBy)==0 ) return 0;
iCol = pIndex->aiColumn[0];
for(ii=0; ii<pOB->nExpr; ii++){
Expr *pExpr = sqlite3ExprSkipCollate(pOB->a[ii].pExpr);
if( pExpr->op!=TK_COLUMN ) return 0;
if( pExpr->iTable==iCursor ){
if( pExpr->iColumn==iCol ) return 1;
return 0;
for(jj=0; jj<pIndex->nColumn; jj++){
if( pExpr->iColumn==pIndex->aiColumn[jj] ) return 1;
}
}
}
return 0;