SQL functions that can be inlined
SQL functions that can be inlined
От:
Jim Nasby <jim@nasby.net>
Дата:
Is there any way to have the database tell you if a particular SQL function can be inlined? -- Jim C. Nasby, Database Architect jim@nasby.net 512.569.9461 (cell) http://jim.nasby.net
Re: SQL functions that can be inlined
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Jim Nasby writes: > Is there any way to have the database tell you if a particular SQL function can be inlined? Easiest way is to EXPLAIN a query using it and see if it did get inlined. For example, regression=# create function foo(int) returns int as regression-# 'select $1 + 1' language sql; CREATE FUNCTION regression=# explain verbose select foo(f1) from int4_tbl; QUERY PLAN ---------------------------------------------------------------Seq Scan on public.int4_tbl (cost=0.00..1.06 rows=5 width=4) Output: (f1 + 1) (2 rows) regression=# create function foo2(int) returns int as 'select $1 + 1 limit 1' language sql; CREATE FUNCTION regression=# explain verbose select foo2(f1) from int4_tbl; QUERY PLAN ---------------------------------------------------------------Seq Scan on public.int4_tbl (cost=0.00..2.30 rows=5 width=4) Output: foo2(f1) (2 rows) regards, tom lane