aboutsummaryrefslogtreecommitdiff
path: root/src/where.c
diff options
context:
space:
mode:
authordrh <>2025-01-19 19:14:21 +0000
committerdrh <>2025-01-19 19:14:21 +0000
commit3640785453c74c6eb8dfeb35d263e9700c594ac2 (patch)
treeb1023e2cc20736d0bdad481d259557e9b0bf1725 /src/where.c
parentc6a39debf9f15c4163b8228f4bf7dd14e76efd97 (diff)
downloadsqlite-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/where.c')
-rw-r--r--src/where.c10
1 files changed, 7 insertions, 3 deletions
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