Advice on setting cost for function - Mailing list pgsql-general

From guyren@relevantlogic.com
Subject Advice on setting cost for function
Date
Msg-id 27621de6-c05b-493c-bf53-49539cb04577@Spark
Whole thread Raw
Responses Re: Advice on setting cost for function
List pgsql-general
The documentation in CREATE FUNCTION is fine as far is it goes regarding the COST setting, but that isn’t very far, and I haven’t had any luck finding good advice.

How do I determine what value to set as the COST of a function? I understand that it’s a relative, abstract, per-row sort of thing, but that’s not quite enough to go on to do it well.

If I have a function that looks up a single value from an index, should that be lower than 100? 20, say?

If I have a function that calls multiple other functions, each of which does a reasonable amount of work, should I set the caller to a higher COST, or will Postgres use the costs of the functions it calls?

I can imagine that a SQL function which is just inlined might ignore the COST estimate. Is that so? Are there other such considerations?

In general, a section in the CREATE FUNCTION documentation of two or three paragraphs with a few examples and general guidelines would be very helpful. I would be happy to write it if someone will explain it to me.

pgsql-general by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: granting right to create and delete just one database
Next
From: Ron
Date:
Subject: Re: configure multiple repository path in pgbackrest