aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/shell.c.in1
-rw-r--r--src/sqliteInt.h1
-rw-r--r--src/where.c10
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