次のクエリ間でパフォーマンスに違いはありますか?濾過セットPostgresql:フィルタ関数の出力と関数へのフィルタパラメータの渡し方
create function foo() returns setof table1 as
$$
select * from table1
$$ language SQL;
select * from foo() where name = 'bar'
2のfoo()のパラメータを受け取り、返し:
create function foo(varchar) returns setof table1 as
$$
select * from table1 where name = $1
$$ language SQL;
select * from foo('bar')
を
1のfoo()は、次いで濾過され、フィルタリングされていないセットを返します私は、DBが最終クエリを計画する前に機能を「インライン化」するほどスマートであると仮定し、実行に差異を生じさせないようにします。確信はないけど。
selectの 'explain analy'は' stable'とデフォルトの違いを示しています。 – astreltsov