Re: The logic behind comparing generic vs. custom plan costs

2025-03-15 Thread Tom Lane
Justin Blank writes: > My idea had been that even if the custom plans average higher cost > than the generic plan, it is still worth considering custom plans. If > 1 time in 5, the custom plan is 10% of the cost of the generic plan, > it doesn't matter if the average custom plan is worse, you shou

Re: The logic behind comparing generic vs. custom plan costs

2025-03-15 Thread David G. Johnston
On Sat, Mar 15, 2025 at 10:42 AM Justin Blank wrote: > My idea had been that even if the custom plans average higher cost > than the generic plan, it is still worth considering custom plans. If > 1 time in 5, the custom plan is 10% of the cost of the generic plan, > it doesn't matter if the avera

The logic behind comparing generic vs. custom plan costs

2025-03-15 Thread Justin Blank
I've been looking into the way that postgres decides whether to use a custom or generic plan. I believe I understand how, but I have confused myself about the why. In plancache.c, the code always executes a custom plan for the first five iterations, and afterwards, it compares the average cost of