> On Nov 2, 2020, at 6:09 PM, Michael Lewis <mlewis@xxxxxxxxxxx> wrote: > > The query I asked about in the original post of this thread has 13 relations in it. IIUC, that's 13! or > 6 billion possible plans. How did the planner pick one plan out of 6 billion? I'm curious, both for practical purposes (I want my query to run well) and also because it's fascinating. > > Have you increased geqo_threshold and join_collapse_limit from the defaults? Yes, thanks you, I should have said that. We avoid the GEQO, so geqo_threshold=25, and join_collapse_limit=from_collapse_limit=24. We tend to have long running queries, so we’re happy to pay a few seconds of extra planner cost to increase the likelihood of getting a better plan. Cheers Philip