| From: | Thomas Kellerer <shammat(at)gmx(dot)net> |
|---|---|
| To: | Pgsql Performance <pgsql-performance(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Out of memory error |
| Date: | 2021-11-24 12:12:14 |
| Message-ID: | f8952c15-6cde-2a0a-b095-cfedd34ba734@gmx.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-performance |
aditya desai schrieb am 24.11.2021 um 08:31:
> H Michael,
> Please see insert_info function below. Also r_log_message is composite data type and it's definition is also given below.
>
> CREATE OR REPLACE FUNCTION insert_info(
> info_array r_log_message[]
> ) RETURNS varchar AS $$
> DECLARE
> info_element r_log_message;
> BEGIN
> FOREACH info_element IN ARRAY info_array
> LOOP
> INSERT INTO testaditya(
> columname,
> oldvalue,
> newvalue
> ) VALUES(
> info_element.column_name,
> info_element.oldvalue,
> info_element.newvalue
> );
> END LOOP;
> RETURN 'OK';
> END;
> $$ LANGUAGE plpgsql;
You don't need a loop for that. This can be done more efficiently using unnest()
INSERT INTO testaditya(columname,oldvalue,newvalue)
select u.*
from unnest(info_array) as u;
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tomas Vondra | 2021-11-24 12:22:00 | Re: Postgres process count GCC vs Clang is Different on autovaccum=on |
| Previous Message | Thomas Kellerer | 2021-11-24 12:10:45 | Re: Out of memory error |