3 ms·
> The applied heuristic in this case apparently being "join tables by order of lower row count". Not really - it's all cost based analysis. There are a few mai
by anarazel 3y ago
> The applied heuristic in this case apparently being "join tables by order of lower row count".
Not really - it's all cost based analysis. There are a few main culprits that might be at work:
1) Selectivity estimates can get very off if you have cross-column correlations or your joins are over multiple aggregations / DISTINCT or such.
2) Join order planning is exponential in the number of joins. Once there are more than geqo_threshold (default = 12) joins, we don't explore the whole space anymore.
3) If you have more than join_collapse_limit / from_collapse_limit joins, subqueries in the from list, we'll not flatten them anymore, to prevent the join ordering problem to become even harder. It might be worth trying to just increase them with your query.
- bhaak 3y agoInteresting info. Thanks. In my particular case it doesn't help that I only have limited control over the query and the query designer has a bias towards large, complicated db functions.