Outer cost higher than the inner cost

2024-07-26 Thread Stanisław Skonieczny
Hello all postgres developers, Recently pg started to make a query plan, which I can not understand. The pan is here: https://explain.depesz.com/s/Lvw0#source The interesting part is at the top: ``` Aggregate (cost=1132443.98..1132443.99 rows=1 width=24) (actual rows=1 loops=1) -> Merge Join

Re: Outer cost higher than the inner cost

2024-07-26 Thread Tom Lane
=?UTF-8?Q?Stanis=C5=82aw_Skonieczny?= writes: > What bothers me is that the inner plan cost (7430940) is higher than the > outer plan cost (1131699). I think it is estimating (based on knowledge of the ranges of join keys in the two relations) that that input subplan won't need to be run to compl