pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: guyren@relevantlogic.com
To: PG-General Mailing List <pgsql-general@postgresql.org>
Subject: Advice on setting cost for function
Date: Wed, 5 Jun 2019 08:08:04 -0700
Message-ID: <27621de6-c05b-493c-bf53-49539cb04577@Spark> (raw)
References: <73351881-0cd6-4331-817b-2c67747940f5@Spark>

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.

view thread (2+ messages)  latest in thread

Message-ID: <27621de6-c05b-493c-bf53-49539cb04577@Spark>
Permalink:  ../27621de6-c05b-493c-bf53-49539cb04577@Spark/
Also on:    postgresql.org/message-id/27621de6-c05b-493c-bf53-49539cb04577@Spark

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: guyren@relevantlogic.com
  Subject: Re: Advice on setting cost for function
  In-Reply-To: <27621de6-c05b-493c-bf53-49539cb04577@Spark>
  References: <73351881-0cd6-4331-817b-2c67747940f5@Spark> <27621de6-c05b-493c-bf53-49539cb04577@Spark>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox