From: Richard Huxton <dev@archonet.com>
To: Rob Sargent <robjsargent@gmail.com>
Cc: PostgreSQL <pgsql-sql@postgresql.org>
Subject: Re: 'cost' and 'rows' for volitile function
Date: Mon, 08 Jun 2009 18:57:47 +0100
Message-ID: <4A2D511B.3010905@archonet.com> (raw)
In-Reply-To: <4A2D4C46.10801@gmail.com>
References: <4A2D3B9D.1040909@gmail.com>
<4A2D44EB.7030108@archonet.com>
<4A2D476B.5030404@gmail.com>
<4A2D4B8B.1080501@archonet.com>
<4A2D4C46.10801@gmail.com>
Rob Sargent wrote:
> Richard Huxton wrote:
>> If your functions are all called at the top-level then indeed it
>> doesn't matter. At a low level though, telling the planner function F1
>> costs 1000 times more than F2 is useful.
>>
> What scares me about this is that for function such as the ones I'm
> currently using which return a wide range of result set size depending
> on input values. The planner will be mis-informed by a factor of 10 or
> more quite easily.
Well, like I said - it doesn't matter as long as you are calling the
function at the top level. The only option the planner has is "execute
function".
However, it is a real problem for what you might term "irregularly
shaped" functions where the costs/rows varies widely. I seem to recall a
suggestion at one point that the values could be replaced by cost
functions that get the same parameters as the function itself. However,
that's could be expensive to do for every function-call, and especially
since there's not always an obvious way to estimate # rows without
calling the function first. I daresay someone will get around to
handling both options in a clean way at some point, but the ability to
define function costs at all was only added in 8.2 iirc.
--
Richard Huxton
Archonet Ltd
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: dev@archonet.com, robjsargent@gmail.com
Subject: Re: 'cost' and 'rows' for volitile function
In-Reply-To: <4A2D511B.3010905@archonet.com>
* 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