pg.ddx.io pgsql-performance@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Thomas Kellerer <shammat@gmx.net>
To: Pgsql Performance <pgsql-performance@lists.postgresql.org>
Subject: Re: Out of memory error
Date: Wed, 24 Nov 2021 13:12:14 +0100
Message-ID: <f8952c15-6cde-2a0a-b095-cfedd34ba734@gmx.net> (raw )
In-Reply-To: <CAN0SRDHoBqVK13rSr=A4f+AzzAD8SrT0L2z5m6-oh4Tau9U9pQ@mail.gmail.com >
References: <CAN0SRDGg3-wH+y7bNvJQa7cdR4wY+7AqoeHbV0urVfBCszSCqg@mail.gmail.com >
<97240.1637733158@sss.pgh.pa.us >
<CAN0SRDGZeRyxcB-LWKjNQSi0O3tcK_xKPZdhaLvj_8+sbNPoBA@mail.gmail.com >
<4af2ff21-1140-ccbd-5adf-926dc816782f@gmx.net >
<CAN0SRDHZD4AD99AxDoaTEGg=S2cYHjOj0v0jFWSdMbXfbhr3CQ@mail.gmail.com >
<CAHOFxGouFSFZTvWMD=jb8ZFk9f-mmZAtUGJmwAMhZPO6OqTJMg@mail.gmail.com >
<CAN0SRDHoBqVK13rSr=A4f+AzzAD8SrT0L2z5m6-oh4Tau9U9pQ@mail.gmail.com >
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;
view thread (11+ messages) latest in thread
Message-ID: <f8952c15-6cde-2a0a-b095-cfedd34ba734@gmx.net>
Permalink: ../f8952c15-6cde-2a0a-b095-cfedd34ba734@gmx.net/
Also on: postgresql.org/message-id/f8952c15-6cde-2a0a-b095-cfedd34ba734@gmx.net
copy link · copy postgr.es
reply Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: shammat@gmx.net, pgsql-performance@lists.postgresql.org
Subject: Re: Out of memory error
In-Reply-To: <f8952c15-6cde-2a0a-b095-cfedd34ba734@gmx.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox