By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,710 Members | 1,906 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,710 IT Pros & Developers. It's quick & easy.

Planner question regarding functions

P: n/a
Hi all;

I suspect I know what the answer here is, but I thought I would ask
anyway. How transparent are SQL language functions from the planner's
perspective? For example if I create a table:

CREATE TABLE proof_of_concept(
poc_id serial primary key,
testing text
);
and a function:

CREATE FUNCTION search_poc() RETURNS setof proof_of_concept AS '
SELECT * FROM proof_of_concept
' LANGUAGE SQL;

Then will the planner be able to use indexes if I do:
SELECT * FROM search_poc() WHERE poc_id = 16023

I am assuming it won't. But can the planner "see inside" the SQL
language functions, thus expanding them similar to a view, or will this
force a sequential scan?

Best Wishes,
Chris Travers
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Mon, Dec 08, 2003 at 21:33:48 +0800,
Chris Travers <ch***@travelamericas.com> wrote:

I suspect I know what the answer here is, but I thought I would ask
anyway. How transparent are SQL language functions from the planner's
perspective? For example if I create a table:


In 7.4 simple SQL functions are inlined and work a lot like macros.
I don't know if set returning functions are able to be inlined.

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 12 '05 #2

P: n/a
Bruno Wolff III <br***@wolff.to> writes:
Chris Travers <ch***@travelamericas.com> wrote:
I suspect I know what the answer here is, but I thought I would ask
anyway. How transparent are SQL language functions from the planner's
perspective? For example if I create a table:
In 7.4 simple SQL functions are inlined and work a lot like macros.
I don't know if set returning functions are able to be inlined.


They are not. I suppose that a function consisting of just one SELECT
could be expanded in-line if it appears in FROM ... but it's not clear
what that accomplishes that you couldn't do just as well with a view.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.