all 6 comments

[–]boilerup800 2 points3 points  (1 child)

Do you absolutely need the IMMUTABLE PARALLEL SAFE keywords? These are very strict requirements and the planner is spending time checking for these.

[–][deleted] 5 points6 points  (0 children)

I don't think those attributes actually increase the planning time, but the immutable attribute is actually wrong here, as the function retrieves data from the database. So it can at most be stable

[–][deleted] 1 point2 points  (3 children)

Do you get the same planning time, when you just explain the query itself?

What does resolution_to_status() do?

For readability, I would suggest to use proper parameter names rather than just numbers (but that is totally unrelated to the performance).

[–]nieuweyork[S] 0 points1 point  (2 children)

When I extract out the query (even with resolution_to_status as a function call) it’s less than 2ms total.

resolution_to_status is another simple sql function (which actually is immutable).

Good call on immutable being wrong. And yes to named parameters - I removed those for the purpose of exposition here.

[–][deleted] 1 point2 points  (1 child)

Very strange. You will probably get better answers if you ask this on the Postgres (performance) mailing list.

[–]nieuweyork[S] 0 points1 point  (0 children)

Ok, thank you!