Re: stable function called for every row?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gerhard Heift <ml-postgresql-20081012-3518(at)gheift(dot)de>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: stable function called for every row?
Date: 2009-01-07 20:52:06
Message-ID: 4158.1231361526@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Gerhard Heift <ml-postgresql-20081012-3518(at)gheift(dot)de> writes:
> The function is called for every row in the table if it is stable or
> volatile and only once if it is immutable?

Yes, possibly.

> I thought it had to be called only once, if it is stable.

No. Stable means that it is *okay* to call it only once per query,
not that that is *guaranteed* to happen. (What it really does is give
the planner license to use an indexscan on a condition involving the
function --- an indexscan's comparison value is evaluated just once,
so it would give the wrong answers for a non-stable function.)

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message c k 2009-01-07 21:17:15 Fail of a return query from plpgsql function for a specific table
Previous Message Tom Lane 2009-01-07 20:44:47 Re: SPI_ERROR_CONNECT in plperl function