Re: Three types of functions, ala function redux.

From: mlw <markw(at)mohawksoft(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Hackers List <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Three types of functions, ala function redux.
Date: 2000-12-21 18:44:59
Message-ID: 3A424FAB.72A8873A@mohawksoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
>
> mlw <markw(at)mohawksoft(dot)com> writes:
> > There are three basic types of SQL behaviors that should be able to be
> > performed.
>
> > (1) "function()" returns a single value. Postgres should be able to
> > understand how to optimize this to be: "select * from table where col =
> > value" where value is the datum returned by function.
>
> You get this now if the function is marked proiscachable.

Doh! RTFM!

>
> > (2) "function()" returns a number of values that are independent of the
> > query. Postgres should be able to optimize this to be: "select * from
> > table where col in (val1, val2, val3, ..valn)." I guess Postgres can
> > loop until done, using the isDone flag?
>
> I object to the notion that "scalar = set" should be automatically
> transformed into "scalar IN set". It would be nice to be smarter about
> optimizing IN operations where the subselect only returns a few rows
> into multiple indexscans, but how should the planner know that in advance?

That is sort of my point. If one marks a function as "Iscachable" and
returns an isDone as false, will postgres keep calling until all values
have been returned, and then use an index scan with the finite (cached?)
set of results?

If so, this is exactly what I need.

>
> > (3) "function()" returns a value based on the query. (This seems to be
> > how it currently functions.) where "select * from table where col =
> > function()" will end up doing a full table scan.
>
> You get this now if the function is not marked proiscachable.

A lot of my confusion has cleared, the "iscachable" flag is an
enlightenment. Boy am I schmuck. ;-}

--
http://www.mohawksoft.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alfred Perlstein 2000-12-21 19:03:08 externalizing PGresult?
Previous Message Peter Eisentraut 2000-12-21 18:41:41 Re: [HACKERS] PostgreSQL pre-7.1 Linux/Alpha Status...