Function query efficiency and optimization - Mailing list pgsql-novice

From Dan Castido
Subject Function query efficiency and optimization
Date
Msg-id 650049.11800.qm@web24812.mail.ird.yahoo.com
Whole thread Raw
Responses Re: Function query efficiency and optimization  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-novice
Hi.

Assuming I have a function like:

CREATE FUNCTION f () RETURNS SETOF INTEGER LANGUAGE PLPgSQL AS
$$
BEGIN
RETURN QUERY SELECT * FROM t;
END;
$$;

And I call:

SELECT * FROM f LIMIT 10;

Is Postgres smart enough to ensure that the function won't do a full scan of the table and then discard all but ten
results?

I'm trying to work out if i can structure things so that i can reuse most of the functions for different queries by
progressivelylayering limits, offsets, etc. 





pgsql-novice by date:

Previous
From: Dan Castido
Date:
Subject: ...
Next
From: Tom Lane
Date:
Subject: Re: Function query efficiency and optimization