Hi, On 2022-03-30 09:05:44 +1300, David Rowley wrote: > I really believe that the main problem here is that JIT only enables > when the *total* plan cost reaches a certain threshold.
Yes, that is/was a clear design mistake. It wasn't quite as bad back when it was written - partitioning blows the problem up by an order of magnitude or three. . The costing really needs to at least multiply the number of to-be-compiled expressions with some cost to decide whether the cost of JITing is worth it, rather than making "flat" decision. > I did propose a patch to address this in [1]. It does need more work > and I do plan to come back to it for v16. FWIW, that doesn't seem quite right - won't it stop JITing e.g. on the inner side of a nested loop, just because it's cheap, even though that's where the bulk of the benefits comes from? Greetings, Andres Freund