Re: Views versus user-defined functions: formatting, comments, performance, etc.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David Johnston" <polobo(at)yahoo(dot)com>
Cc: "'Merlin Moncure'" <mmoncure(at)gmail(dot)com>, "'Adam Mackler'" <adammackler(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Views versus user-defined functions: formatting, comments, performance, etc.
Date: 2012-08-18 02:00:14
Message-ID: 10411.1345255214@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"David Johnston" <polobo(at)yahoo(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Chris Travers 2012-08-18 02:40:58 Re: Views versus user-defined functions: formatting, comments, performance, etc.
Previous Message David Johnston 2012-08-18 00:13:17 Re: Views versus user-defined functions: formatting, comments, performance, etc.