Merlin Moncure <mmoncure(at)gmail(dot)com> writes:
> In my experience virtually no useful functions are inlined by the
> planner. For example, with function:
> create function f(text) returns date as $$
> select to_date($1, 'YYYY'); $$
> language sql stable; /* immutable doesn't help */
> I see about 4x time difference between:
> select to_date(v::text, 'YYYY') from generate_series(1,100000) v;
> and
> select f(v::text) from generate_series(1,100000) v;
Something wrong with your measurement technique, because those expand
to identical plan trees for me.
regards, tom lane