Re: Not use index on setof from Sql Function

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Alessandro Vincelli <a(dot)vincelli(at)w4b(dot)it>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Not use index on setof from Sql Function
Date: 2005-03-09 17:15:16
Message-ID: 20050309171450.GF1239@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Mar 09, 2005 at 04:49:28PM +0100, Alessandro Vincelli wrote:
>
> This simple function return setof table "DatiRegione"
>
>
> CREATE OR REPLACE FUNCTION public._stato_dati_regione_rt(text)
> RETURNS SETOF "DatiRegione" AS
> '
> SELECT DISTINCT ON ("Codice_regione") dr.* FROM "DatiRegione"
> '
> LANGUAGE 'sql' VOLATILE STRICT;

You can't do an index scan on a function. As far as the executor is
concerned, a function is an opaque object. Perhaps you actually want a
view? They allow optimisations like the one you're looking for...

Hope this helps,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message marcelo Cortez 2005-03-09 17:28:55 segmentation fault
Previous Message Joshua D. Drake 2005-03-09 17:14:02 Re: PostgreSQL still for Linux only?