From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Jim Nasby <jim(at)nasby(dot)net> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: SQL functions that can be inlined |
Date: | 2010-11-06 15:53:00 |
Message-ID: | 19899.1289058780@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Jim Nasby <jim(at)nasby(dot)net> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2010-11-06 16:04:14 | Re: PL/pgSQL and shared_preload_libraries |
Previous Message | Tom Lane | 2010-11-06 15:48:27 | Re: Protecting against unexpected zero-pages: proposal |