Re: IMMUTABLE break inlining simple SQL functions.
От | Tom Lane |
---|---|
Тема | Re: IMMUTABLE break inlining simple SQL functions. |
Дата | |
Msg-id | 451.1249230559@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | IMMUTABLE break inlining simple SQL functions. (Pavel Stehule <pavel.stehule@gmail.com>) |
Список | pgsql-hackers |
Pavel Stehule <pavel.stehule@gmail.com> writes: > I though, so simple SQL functions should be inlined everywhere. When I > tested sample for recent discussion, I found so immutable flag breaks > inlining. Your example proves nothing of the sort, since you have forgotten to allow for immutable functions being folded to constants. Actually, AFAICS both of these cases end up being folded to a constant, but I think the processing path is different --- one will just be evaluated on sight, the other gets inlined and is then seen to be a constant expression: regression=# create or replace function foo(a int) returns int as $$ regression$# select $1+1$$ language sql STRICT IMMUTABLE; CREATE FUNCTION regression=# explain verbose select foo(12); QUERY PLAN ------------------------------------------Result (cost=0.00..0.01 rows=1 width=0) Output: 13 (2 rows) regression=# create or replace function foo(a int) returns int as $$ select $1+1$$ language sql STRICT ; CREATE FUNCTION regression=# explain verbose select foo(12); QUERY PLAN ------------------------------------------Result (cost=0.00..0.01 rows=1 width=0) Output: 13 (2 rows) The fact that it gets inlined rather than evaluated per se is probably why the stats counter isn't affected. regards, tom lane
В списке pgsql-hackers по дате отправления: