diff options
author | drh <> | 2025-01-19 19:14:21 +0000 |
---|---|---|
committer | drh <> | 2025-01-19 19:14:21 +0000 |
commit | 3640785453c74c6eb8dfeb35d263e9700c594ac2 (patch) | |
tree | b1023e2cc20736d0bdad481d259557e9b0bf1725 /src | |
parent | c6a39debf9f15c4163b8228f4bf7dd14e76efd97 (diff) | |
download | sqlite-3640785453c74c6eb8dfeb35d263e9700c594ac2.tar.gz sqlite-3640785453c74c6eb8dfeb35d263e9700c594ac2.zip |
Add an SQLITE_TESTCTRL_OPTIMIZATION mask that can disable the query planner
heuristics that are designed to help with star queries.
FossilOrigin-Name: fec4ff185a2f3f1bee8f27432206276636cf27365d2d41cd7282f8c0425f2e96
Diffstat (limited to 'src')
-rw-r--r-- | src/shell.c.in | 1 | ||||
-rw-r--r-- | src/sqliteInt.h | 1 | ||||
-rw-r--r-- | src/where.c | 10 |
3 files changed, 9 insertions, 3 deletions
diff --git a/src/shell.c.in b/src/shell.c.in index 17054a961..d7a0bf55b 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -11475,6 +11475,7 @@ static int do_meta_command(char *zLine, ShellState *p){ { 0x04000000, 1, "NullUnusedCols" }, { 0x08000000, 1, "OnePass" }, { 0x10000000, 1, "OrderBySubq" }, + { 0x20000000, 1, "StarQuery" }, { 0xffffffff, 0, "All" }, }; unsigned int curOpt; diff --git a/src/sqliteInt.h b/src/sqliteInt.h index b8c9136a5..3045d7c4a 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1889,6 +1889,7 @@ struct sqlite3 { #define SQLITE_NullUnusedCols 0x04000000 /* NULL unused columns in subqueries */ #define SQLITE_OnePass 0x08000000 /* Single-pass DELETE and UPDATE */ #define SQLITE_OrderBySubq 0x10000000 /* ORDER BY in subquery helps outer */ +#define SQLITE_StarQuery 0x20000000 /* Heurists for star queries */ #define SQLITE_AllOpts 0xffffffff /* All optimizations */ /* diff --git a/src/where.c b/src/where.c index b867e615f..0b8e5acea 100644 --- a/src/where.c +++ b/src/where.c @@ -5459,7 +5459,10 @@ static LogEst whereSortingCost( */ static int computeMxChoice(WhereInfo *pWInfo, LogEst nRowEst){ int nLoop = pWInfo->nLevel; /* Number of terms in the join */ - if( nRowEst==0 && nLoop>=5 ){ + if( nRowEst==0 + && nLoop>=5 + && OptimizationEnabled(pWInfo->pParse->db, SQLITE_StarQuery) + ){ /* Check to see if we are dealing with a star schema and if so, reduce ** the cost of fact tables relative to dimension tables, as a heuristic ** to help keep the fact tables in outer loops. @@ -5487,8 +5490,9 @@ static int computeMxChoice(WhereInfo *pWInfo, LogEst nRowEst){ #ifdef WHERETRACE_ENABLED /* 0x4 */ if( sqlite3WhereTrace&0x4 ){ SrcItem *pItem = pWInfo->pTabList->a + iLoop; - sqlite3DebugPrintf("Fact-table %s: %d dimensions, cost reduced %d\n", - pItem->zAlias ? pItem->zAlias : pItem->pSTab->zName, + sqlite3DebugPrintf( + "Fact-table %s(%d): %d dimensions, cost reduced %d\n", + pItem->zAlias ? pItem->zAlias : pItem->pSTab->zName, iLoop, nDep, rDelta); } #endif |