Re: Views versus user-defined functions: formatting, comments, performance, etc. - Mailing list pgsql-general

From Tom Lane
Subject Re: Views versus user-defined functions: formatting, comments, performance, etc.
Date
Msg-id 10411.1345255214@sss.pgh.pa.us
Whole thread Raw
In response to Re: Views versus user-defined functions: formatting, comments, performance, etc.  ("David Johnston" <polobo@yahoo.com>)
List pgsql-general
"David Johnston" <polobo@yahoo.com> writes:
> Trying to answer the previous question this one presented itself:  I just
> tried a couple of very simple queries and couldn't get them give me a plan
> that wasn't a "Function Scan".  Is it possible that only "scalar" functions
> can be inlined?

> CREATE OR REPLACE FUNCTION three_col_func()
> RETURNS TABLE (col1 varchar, col2 varchar, col3 varchar)
> AS $$
>    SELECT '1'::varchar, '2'::varchar, '3'::varchar;
> $$
> LANGUAGE sql
> VOLATILE
> ROWS 1
> ;

No, the problem with that one is that it's marked VOLATILE, which has a
whole set of implications that wouldn't be replicated by an inline
subquery.  Try marking it STABLE instead.

There are a pile of other poorly-documented restrictions as well...
one that I notice in a quick look at inline_set_returning_function
is that the function can't be marked STRICT.

            regards, tom lane


pgsql-general by date:

Previous
From: "David Johnston"
Date:
Subject: Re: Views versus user-defined functions: formatting, comments, performance, etc.
Next
From: Evan Stanford
Date:
Subject: Fwd: PSQL Help from your biggest fan