<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Waiting for 8.4 &#8211; pl/* srf functions in selects</title>
	<atom:link href="http://www.depesz.com/index.php/2008/11/03/waiting-for-84-pl-srf-functions-in-selects/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.depesz.com/index.php/2008/11/03/waiting-for-84-pl-srf-functions-in-selects/</link>
	<description></description>
	<lastBuildDate>Tue, 16 Mar 2010 17:19:22 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: depesz</title>
		<link>http://www.depesz.com/index.php/2008/11/03/waiting-for-84-pl-srf-functions-in-selects/comment-page-1/#comment-27182</link>
		<dc:creator>depesz</dc:creator>
		<pubDate>Tue, 16 Dec 2008 09:22:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/?p=1305#comment-27182</guid>
		<description>@Sergey:
# select i, (test(1, i)).* from generate_series(1,3) i;
 i &#124; numerical &#124; textual
---+-----------+---------
 1 &#124;         1 &#124; i = 1
 2 &#124;         1 &#124; i = 1
 2 &#124;         2 &#124; i = 2
 3 &#124;         1 &#124; i = 1
 3 &#124;         2 &#124; i = 2
 3 &#124;         3 &#124; i = 3
(6 rows)</description>
		<content:encoded><![CDATA[<p>@Sergey:<br />
# select i, (test(1, i)).* from generate_series(1,3) i;<br />
 i | numerical | textual<br />
&#8212;+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;<br />
 1 |         1 | i = 1<br />
 2 |         1 | i = 1<br />
 2 |         2 | i = 2<br />
 3 |         1 | i = 1<br />
 3 |         2 | i = 2<br />
 3 |         3 | i = 3<br />
(6 rows)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sergey Konoplev</title>
		<link>http://www.depesz.com/index.php/2008/11/03/waiting-for-84-pl-srf-functions-in-selects/comment-page-1/#comment-27178</link>
		<dc:creator>Sergey Konoplev</dc:creator>
		<pubDate>Mon, 15 Dec 2008 23:30:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/?p=1305#comment-27178</guid>
		<description>Hubert, woud it be possible to do the same this way?
select i, (test(1, i)).* from generate_series(1,3) i;</description>
		<content:encoded><![CDATA[<p>Hubert, woud it be possible to do the same this way?<br />
select i, (test(1, i)).* from generate_series(1,3) i;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: depesz</title>
		<link>http://www.depesz.com/index.php/2008/11/03/waiting-for-84-pl-srf-functions-in-selects/comment-page-1/#comment-26943</link>
		<dc:creator>depesz</dc:creator>
		<pubDate>Mon, 03 Nov 2008 15:01:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/?p=1305#comment-26943</guid>
		<description>@David:
heh, CTEs are so new that I simply forgot about them, but here is goes:

with source as (
  select i, test(1, i) from generate_series(1,3) i
)
select i, (test).numerical, (test).textual from source;

but i&#039;m not really sure if this will give better results than the subquery approach. explains look like this:

cte:
                                                         QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------
 CTE Scan on source  (cost=262.50..282.50 rows=1000 width=36) (actual time=0.217..0.426 rows=6 loops=1)
   InitPlan
     -&gt;  Function Scan on generate_series i  (cost=0.00..262.50 rows=1000 width=4) (actual time=0.206..0.382 rows=6 loops=1)
 Total runtime: 0.483 ms
(4 rows)

subquery:
                                                        QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------
 Subquery Scan x  (cost=0.00..272.50 rows=1000 width=36) (actual time=0.200..0.388 rows=6 loops=1)
   -&gt;  Function Scan on generate_series i  (cost=0.00..262.50 rows=1000 width=4) (actual time=0.193..0.358 rows=6 loops=1)
 Total runtime: 0.437 ms
(3 rows)</description>
		<content:encoded><![CDATA[<p>@David:<br />
heh, CTEs are so new that I simply forgot about them, but here is goes:</p>
<p>with source as (<br />
  select i, test(1, i) from generate_series(1,3) i<br />
)<br />
select i, (test).numerical, (test).textual from source;</p>
<p>but i&#8217;m not really sure if this will give better results than the subquery approach. explains look like this:</p>
<p>cte:<br />
                                                         QUERY PLAN<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
 CTE Scan on source  (cost=262.50..282.50 rows=1000 width=36) (actual time=0.217..0.426 rows=6 loops=1)<br />
   InitPlan<br />
     ->  Function Scan on generate_series i  (cost=0.00..262.50 rows=1000 width=4) (actual time=0.206..0.382 rows=6 loops=1)<br />
 Total runtime: 0.483 ms<br />
(4 rows)</p>
<p>subquery:<br />
                                                        QUERY PLAN<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
 Subquery Scan x  (cost=0.00..272.50 rows=1000 width=36) (actual time=0.200..0.388 rows=6 loops=1)<br />
   ->  Function Scan on generate_series i  (cost=0.00..262.50 rows=1000 width=4) (actual time=0.193..0.358 rows=6 loops=1)<br />
 Total runtime: 0.437 ms<br />
(3 rows)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Fetter</title>
		<link>http://www.depesz.com/index.php/2008/11/03/waiting-for-84-pl-srf-functions-in-selects/comment-page-1/#comment-26942</link>
		<dc:creator>David Fetter</dc:creator>
		<pubDate>Mon, 03 Nov 2008 14:55:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/?p=1305#comment-26942</guid>
		<description>Hubert,

Since you&#039;re talking about 8.4 anyhow, you might include CTEs in that last example, as this is one of the places they do wonders for :)</description>
		<content:encoded><![CDATA[<p>Hubert,</p>
<p>Since you&#8217;re talking about 8.4 anyhow, you might include CTEs in that last example, as this is one of the places they do wonders for <img src='http://www.depesz.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: depesz</title>
		<link>http://www.depesz.com/index.php/2008/11/03/waiting-for-84-pl-srf-functions-in-selects/comment-page-1/#comment-26940</link>
		<dc:creator>depesz</dc:creator>
		<pubDate>Mon, 03 Nov 2008 12:42:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/?p=1305#comment-26940</guid>
		<description>@Regina:
Just tested, with function defined as stable or immutable. I checked how many times function was called by adding &quot;raise notice&quot; in it. in all cases it got called twice (i.e. in case of subselect approach it was only once per row).</description>
		<content:encoded><![CDATA[<p>@Regina:<br />
Just tested, with function defined as stable or immutable. I checked how many times function was called by adding &#8220;raise notice&#8221; in it. in all cases it got called twice (i.e. in case of subselect approach it was only once per row).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Regina</title>
		<link>http://www.depesz.com/index.php/2008/11/03/waiting-for-84-pl-srf-functions-in-selects/comment-page-1/#comment-26939</link>
		<dc:creator>Regina</dc:creator>
		<pubDate>Mon, 03 Nov 2008 12:29:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/?p=1305#comment-26939</guid>
		<description>Hubert,

This is neat.  I&#039;ve been waiting for something like this so I don&#039;t have to do an SQL wrapper hack.

One question.  You sure the function currently gets called twice?  I haven&#039;t really tested so can&#039;t be sure.

I was always under the impression that if you set the function to STABLE/IMMUTABLE, then it would only get called once per unique test(1, i).  Otherwise why wouldn&#039;t you be able to put 2 set returning functions in the SELECT and also get multiplicative?

Thanks,
Regina</description>
		<content:encoded><![CDATA[<p>Hubert,</p>
<p>This is neat.  I&#8217;ve been waiting for something like this so I don&#8217;t have to do an SQL wrapper hack.</p>
<p>One question.  You sure the function currently gets called twice?  I haven&#8217;t really tested so can&#8217;t be sure.</p>
<p>I was always under the impression that if you set the function to STABLE/IMMUTABLE, then it would only get called once per unique test(1, i).  Otherwise why wouldn&#8217;t you be able to put 2 set returning functions in the SELECT and also get multiplicative?</p>
<p>Thanks,<br />
Regina</p>
]]></content:encoded>
	</item>
</channel>
</rss>
