Re: Trigger function cost

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: glynastill(at)yahoo(dot)co(dot)uk
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Trigger function cost
Date: 2009-04-09 14:27:43
Message-ID: 13658.1239287263@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Glyn Astill <glynastill(at)yahoo(dot)co(dot)uk> writes:
> I see that when I create a volatile plpgsql trigger function it gets given a cost of 100 and a c function gets given a cost of 1.

> Is there any reason to mess with this?

No. The planner doesn't actually bother to figure the cost of triggers
anyway, since presumably every correct plan will fire the same set of
triggers. So even if you had a more accurate cost estimate than that
one, it wouldn't get used for anything.

Now, for ordinary non-trigger functions, it might be worth paying
some attention to the cost estimate. "1" is intended to denote the
cost of a reasonably simple C function, so PL functions should pretty
much always have costs that are large multiples of that. 100 is a
reasonable default, but if you know better you can put something else.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Marcin Krol 2009-04-09 14:47:32 complicated query (newbie..)
Previous Message Thomas Kellerer 2009-04-09 12:30:40 Re: Postgres: Starting Server in background mode