Skip to content
Discussion options

You must be logged in to vote

We noticed that when calling one of our heavy-duty functions via rpc/, the request was taking twice as much time as expected.

The problem here is not the query, but the planner not knowing that the function you are calling is costly. It assumes it is cheap enough to "optimize" the query by inlining the CTE.

For such a function you can play with the COST parameter in CREATE FUNCTION:

COST execution_cost

A positive number giving the estimated execution cost for the function, in units of cpu_operator_cost. If the function returns a set, this is the cost per returned row. If the cost is not specified, 1 unit is assumed for C-language and internal functions, and 100 units for functions in a…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by wolfgangwalther
Comment options

You must be logged in to vote
3 replies
@wolfgangwalther
Comment options

@steve-chavez
Comment options

@wolfgangwalther
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
3 participants
Converted from issue

This discussion was converted from issue #2108 on February 09, 2022 20:50.