Function query efficiency and optimization

Поиск
Список
Период
Сортировка
От Dan Castido
Тема Function query efficiency and optimization
Дата
Msg-id 650049.11800.qm@web24812.mail.ird.yahoo.com
обсуждение исходный текст
Ответы Re: Function query efficiency and optimization  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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 по дате отправления:

Предыдущее
От: Dan Castido
Дата:
Сообщение: ...
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Function query efficiency and optimization