1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-21 09:00:59 +03:00

More bug fixes to the WhereLoop generator and the solver in NGQP.

Now finds the best plan for TPC-H Q8.  This seems to prove the
concept, but there is still much work to be done.

FossilOrigin-Name: 8e5aad37529ec3042e3468acf15186f566e2df8a
This commit is contained in:
drh
2013-05-08 04:22:59 +00:00
parent f204dac1e3
commit a184fb87b8
3 changed files with 21 additions and 22 deletions

View File

@@ -1,5 +1,5 @@
C Bug\sfixes\sin\sthe\ssolver.
D 2013-05-08T03:22:07.536
C More\sbug\sfixes\sto\sthe\sWhereLoop\sgenerator\sand\sthe\ssolver\sin\sNGQP.\nNow\sfinds\sthe\sbest\splan\sfor\sTPC-H\sQ8.\s\sThis\sseems\sto\sprove\sthe\nconcept,\sbut\sthere\sis\sstill\smuch\swork\sto\sbe\sdone.
D 2013-05-08T04:22:59.354
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in ce81671efd6223d19d4c8c6b88ac2c4134427111
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -263,7 +263,7 @@ F src/vtab.c b05e5f1f4902461ba9f5fc49bb7eb7c3a0741a83
F src/wal.c 436bfceb141b9423c45119e68e444358ee0ed35d
F src/wal.h a4d3da523d55a226a0b28e9058ef88d0a8051887
F src/walker.c 4fa43583d0a84b48f93b1e88f11adf2065be4e73
F src/where.c 22da73b779e8892a59fcd03835ddf7c3e63a305c
F src/where.c c02037efa641eb9f60f054a52bc4ef3c8230369a
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
F test/aggnested.test 45c0201e28045ad38a530b5a144b73cd4aa2cfd6
@@ -1060,7 +1060,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 5d37587c50d8932b6357bfd03152a851510a4317
R 0e4e284cdf8cf22ac3d57735e7fe3f80
P b36034bbd19bc5677b26a6f60ca96eb2b37db373
R 133717a86de1df991cb6332a4c908d9a
U drh
Z bad1f86f1f7d261e6176b4a4726658c0
Z f247935a6bdcd4102bf6e24d9a3606bf

View File

@@ -1 +1 @@
b36034bbd19bc5677b26a6f60ca96eb2b37db373
8e5aad37529ec3042e3468acf15186f566e2df8a

View File

@@ -710,15 +710,6 @@ WhereTerm *whereScanNext(WhereScan *pScan){
iColumn = pScan->aEquiv[pScan->iEquiv-1];
while( (pWC = pScan->pWC)!=0 ){
for(pTerm=pWC->a+pScan->k; pScan->k<pWC->nTerm; pScan->k++, pTerm++){
if( pTerm->iParent>=0 ){
WhereTerm *pParent = &pWC->a[pTerm->iParent];
int j;
for(j=pScan->iEquiv-4; j>=0; j-=2 ){
if( pParent->leftCursor==pScan->aEquiv[j]
&& pParent->u.leftColumn==pScan->aEquiv[j+1] ) break;
}
if( j>=0 ) continue;
}
if( pTerm->leftCursor==iCur && pTerm->u.leftColumn==iColumn ){
if( (pTerm->eOperator & WO_EQUIV)!=0
&& pScan->nEquiv<ArraySize(pScan->aEquiv)
@@ -754,6 +745,13 @@ WhereTerm *whereScanNext(WhereScan *pScan){
continue;
}
}
if( (pTerm->eOperator & WO_EQ)!=0
&& (pX = pTerm->pExpr->pRight)->op==TK_COLUMN
&& pX->iTable==pScan->aEquiv[0]
&& pX->iColumn==pScan->aEquiv[1]
){
continue;
}
pScan->pCurrent = pTerm;
pScan->k++;
return pTerm;
@@ -5058,13 +5056,14 @@ static void whereLoopPrint(WhereLoop *p, SrcList *pTabList){
int nb = 2*((pTabList->nSrc+15)/16);
struct SrcList_item *pItem = pTabList->a + p->iTab;
Table *pTab = pItem->pTab;
sqlite3DebugPrintf("%02d.%0*llx", p->iTab, nb, p->prereq);
sqlite3DebugPrintf(" %6s",
sqlite3DebugPrintf("%2d.%0*llx.%0*llx",
p->iTab, nb, p->maskSelf, nb, p->prereq);
sqlite3DebugPrintf(" %8s",
pItem->zAlias ? pItem->zAlias : pTab->zName);
if( p->pIndex ){
sqlite3DebugPrintf(".%-8s %2d", p->pIndex->zName, p->nEq);
sqlite3DebugPrintf(".%-12s %2d", p->pIndex->zName, p->nEq);
}else{
sqlite3DebugPrintf("%12s","");
sqlite3DebugPrintf("%16s","");
}
sqlite3DebugPrintf(" fg %08x OB %d,%d N %2d",
p->wsFlags, p->iOb, p->nOb, p->nTerm);
@@ -5282,7 +5281,7 @@ static void whereLoopAddBtree(
pNew = pBuilder->pNew;
db = pBuilder->db;
pSrc = pBuilder->pTabList->a + iTab;
pNew->maskSelf = getMask(pBuilder->pWC->pMaskSet, iTab);
pNew->maskSelf = getMask(pBuilder->pWC->pMaskSet, pSrc->iCursor);
if( pSrc->pIndex ){
/* An INDEXED BY clause specifies a particular index to use */
@@ -5460,7 +5459,7 @@ static int wherePathSolver(WhereInfo *pWInfo){
if( nTo<mxChoice ){
jj = nTo++;
}else{
for(jj=nTo-1; aTo[jj].rCost>=mxCost; jj++){ assert(jj>0); }
for(jj=nTo-1; aTo[jj].rCost>=mxCost; jj--){ assert(jj>0); }
}
pTo = &aTo[jj];
}else{