| From: | Alexander Shereshevsky <shereshevsky(at)gmail(dot)com> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | record from plpgsql function performance |
| Date: | 2015-07-02 14:31:37 |
| Message-ID: | CAJMMYvoDErqtVuSFR4U1g28jMBxVTfJXYHQ_5S9nVDwy-bbA6w@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Hello,
I have some simple function. The returned data set is generated based on
view (dynamic - can be changed on daily basis).
So the function was defined this way:
1. returns setof some_view as ...
2. inside the function I'm generating dynamic SQL into v_sql variable.
3. return query execute v_sql
Everything works fine if I'm running single function, like:
select * from function (param1, param2)
I'm getting the delimited fields in desired order.
But if I want to run the function in inline mode, like:
select function(param1, param2) from some_table;
so the returned datatype is record.
To return multiple fields, I'm trying to use:
select (function(param1, param2)).* from some_table;
But this operation has a huge performance impact, IMHO runtime multiplied
by number of columns - the function is executed for each column separately.
In my case normal inline run is about 2 seconds for 300-400 records, but
with ().* it's increased to 90-120 seconds.
Thank you in advance if you can suggest me the better way.
BR,
Alexander Shereshevsky
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David G. Johnston | 2015-07-02 14:47:55 | Re: record from plpgsql function performance |
| Previous Message | Sylvain MARECHAL | 2015-07-02 14:11:53 | Getting the value of the old_tuple using the test_decoding extension and BDR |