Improvements to ORDER BY handling in the NGQP. Fix an "exit" mistakenly
left in a test script during the previous check-in. FossilOrigin-Name: 12c709b4369c7d94d7fb743d0d0da7a9350a3d16
This commit is contained in:
parent
d15cb17174
commit
a50ef114f4
14
manifest
14
manifest
@ -1,5 +1,5 @@
|
||||
C Enhanced\s"wheretrace"\soutput\sin\sthe\sNGQP\ssolver\sroutine.
|
||||
D 2013-05-21T19:23:10.944
|
||||
C Improvements\sto\sORDER\sBY\shandling\sin\sthe\sNGQP.\s\sFix\san\s"exit"\smistakenly\nleft\sin\sa\stest\sscript\sduring\sthe\sprevious\scheck-in.
|
||||
D 2013-05-22T02:06:59.780
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in f6b58b7bdf6535f0f0620c486dd59aa4662c0b4f
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@ -265,7 +265,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 759c34becf7a414b4bebddd30ad65109eb4510fc
|
||||
F src/where.c b695db3fe80456a57461c43f1fa1596a38fb4652
|
||||
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
|
||||
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
||||
F test/aggnested.test 45c0201e28045ad38a530b5a144b73cd4aa2cfd6
|
||||
@ -324,7 +324,7 @@ F test/boundary1.test 66d7f4706ccdb42d58eafdb081de07b0eb42d77b
|
||||
F test/boundary2.tcl e34ef4e930cf1083150d4d2c603e146bd3b76bcb
|
||||
F test/boundary2.test 9ae758d7dab7e882c8b6cc4a6a10278385bff8fa
|
||||
F test/boundary3.tcl 8901d6a503d0bf64251dd81cc74e5ad3add4b119
|
||||
F test/boundary3.test 04c269017471f1562da2dd6310359f16073a2a65
|
||||
F test/boundary3.test 56ef82096b4329aca2be74fa1e2b0f762ea0eb45
|
||||
F test/boundary4.tcl 0bb4b1a94f4fc5ae59b79b9a2b7a140c405e2983
|
||||
F test/boundary4.test 89e02fa66397b8a325d5eb102b5806f961f8ec4b
|
||||
F test/btreefault.test f52c593513bda80a506c848325c73c840590884d
|
||||
@ -1065,7 +1065,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
|
||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
|
||||
F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
|
||||
P 67367f1e1f0c3eb6be65eea9873910aa62b49884
|
||||
R 26b15d08d00e63218ca6971b3d46c9f6
|
||||
P 04dfb85a2a7025d4b5056b73fa8477691323919f
|
||||
R b7bf12d6215811537a2285f41fc9e19a
|
||||
U drh
|
||||
Z 6ae4459022aa081e691ba708466a0da1
|
||||
Z 6465b78fdb5633463ec5d8b46a4226e0
|
||||
|
@ -1 +1 @@
|
||||
04dfb85a2a7025d4b5056b73fa8477691323919f
|
||||
12c709b4369c7d94d7fb743d0d0da7a9350a3d16
|
27
src/where.c
27
src/where.c
@ -5961,7 +5961,7 @@ static const char *wherePathName(WherePath *pPath, int nLoop, WhereLoop *pLast){
|
||||
** Return SQLITE_OK on success or SQLITE_NOMEM of a memory allocation
|
||||
** error occurs.
|
||||
*/
|
||||
static int wherePathSolver(WhereInfo *pWInfo){
|
||||
static int wherePathSolver(WhereInfo *pWInfo, double nRowEst){
|
||||
const int mxChoice = 10; /* Maximum number of simultaneous paths tracked */
|
||||
int nLoop; /* Number of terms in the join */
|
||||
sqlite3 *db; /* The database connection */
|
||||
@ -5976,7 +5976,6 @@ static int wherePathSolver(WhereInfo *pWInfo){
|
||||
WherePath *pFrom; /* An element of aFrom[] that we are working on */
|
||||
WherePath *pTo; /* An element of aTo[] that we are working on */
|
||||
WhereLoop *pWLoop; /* One of the WhereLoop objects */
|
||||
WhereLoop *pNext; /* Next loop */
|
||||
WhereLoop **pX; /* Used to divy up the pSpace memory */
|
||||
char *pSpace; /* Temporary memory used by this routine */
|
||||
|
||||
@ -6003,10 +6002,11 @@ static int wherePathSolver(WhereInfo *pWInfo){
|
||||
/* Precompute the cost of sorting the final result set, if the caller
|
||||
** to sqlite3WhereBegin() was concerned about sorting */
|
||||
rSortCost = (double)0;
|
||||
if( pWInfo->pOrderBy==0 ){
|
||||
if( pWInfo->pOrderBy==0 || nRowEst<0.0 ){
|
||||
aFrom[0].isOrderedValid = 1;
|
||||
}else{
|
||||
/* Compute an estimate on the cost to sort the entire result set */
|
||||
#if 0
|
||||
rSortCost = (double)1;
|
||||
for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pNext){
|
||||
pNext = pWLoop->pNextLoop;
|
||||
@ -6018,6 +6018,14 @@ static int wherePathSolver(WhereInfo *pWInfo){
|
||||
rSortCost *= rCost;
|
||||
}
|
||||
rSortCost *= estLog(rSortCost);
|
||||
#else
|
||||
rSortCost = nRowEst*estLog(nRowEst);
|
||||
#endif
|
||||
#ifdef WHERETRACE_ENABLED
|
||||
if( sqlite3WhereTrace>=2 ){
|
||||
sqlite3DebugPrintf("--solver sort cost=%-7.2g\n", rSortCost);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Compute successively longer WherePaths using the previous generation
|
||||
@ -6134,10 +6142,10 @@ static int wherePathSolver(WhereInfo *pWInfo){
|
||||
|
||||
#ifdef WHERETRACE_ENABLED
|
||||
if( sqlite3WhereTrace>=2 ){
|
||||
sqlite3DebugPrintf("---- round %d ----\n", iLoop);
|
||||
sqlite3DebugPrintf("---- after round %d ----\n", iLoop);
|
||||
for(ii=0, pTo=aTo; ii<nTo; ii++, pTo++){
|
||||
sqlite3DebugPrintf("%2d: %s cost=%-7.2g nrow=%-7.2g order=%c\n",
|
||||
ii, wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,
|
||||
sqlite3DebugPrintf(" %s cost=%-7.2g nrow=%-7.2g order=%c\n",
|
||||
wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,
|
||||
pTo->isOrderedValid ? (pTo->isOrdered ? 'Y' : 'N') : '?');
|
||||
}
|
||||
}
|
||||
@ -6167,6 +6175,7 @@ static int wherePathSolver(WhereInfo *pWInfo){
|
||||
if( pFrom->isOrdered ){
|
||||
pWInfo->nOBSat = pWInfo->pOrderBy->nExpr;
|
||||
}
|
||||
pWInfo->nRowOut = pFrom->nRow;
|
||||
|
||||
/* Free temporary memory and return success */
|
||||
sqlite3DbFree(db, pSpace);
|
||||
@ -6432,8 +6441,12 @@ WhereInfo *sqlite3WhereBegin(
|
||||
}
|
||||
#endif
|
||||
|
||||
wherePathSolver(pWInfo);
|
||||
wherePathSolver(pWInfo, -1);
|
||||
if( db->mallocFailed ) goto whereBeginError;
|
||||
if( pWInfo->pOrderBy ){
|
||||
wherePathSolver(pWInfo, pWInfo->nRowOut);
|
||||
if( db->mallocFailed ) goto whereBeginError;
|
||||
}
|
||||
#ifdef WHERETRACE_ENABLED
|
||||
if( sqlite3WhereTrace ){
|
||||
int ii;
|
||||
|
@ -123,7 +123,6 @@ do_test boundary3-2.1.3 {
|
||||
SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=17
|
||||
}
|
||||
} {72057594037927935 00ffffffffffffff}
|
||||
exit
|
||||
do_test boundary3-2.1.gt.1 {
|
||||
db eval {
|
||||
SELECT t2.a FROM t1 JOIN t2 USING(a)
|
||||
|
Loading…
Reference in New Issue
Block a user