Re: Does it make sense to break a large query into separate functions?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: Seref Arikan <serefarikan(at)kurumsalteknoloji(dot)com>, PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Does it make sense to break a large query into separate functions?
Date: 2013-05-08 16:12:57
Message-ID: 950.1368029577@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jerry Sievers 2013-05-08 16:23:51 Re: SELECT count(*) differs from result in pgadmin
Previous Message Raghavendra 2013-05-08 16:03:33 Re: PAM implementation in PG 9.2.3