Re: Out of memory error

From: aditya desai <admad123(at)gmail(dot)com>
To: Michael Lewis <mlewis(at)entrata(dot)com>
Cc: Thomas Kellerer <shammat(at)gmx(dot)net>, Pgsql Performance <pgsql-performance(at)lists(dot)postgresql(dot)org>
Subject: Re: Out of memory error
Date: 2021-11-24 07:31:18
Message-ID: CAN0SRDHoBqVK13rSr=A4f+AzzAD8SrT0L2z5m6-oh4Tau9U9pQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

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;

postgres=# \d r_log_message;
Composite type "public.r_log_message"
Column | Type | Collation | Nullable | Default
-------------+-------------------------+-----------+----------+---------
column_name | character varying(30) | | |
oldvalue | character varying(4000) | | |
newvalue | character varying(4000) | | |

Regards,
Aditya.

On Wed, Nov 24, 2021 at 12:16 PM Michael Lewis <mlewis(at)entrata(dot)com> wrote:

> It seems like that function has some syntax errors, and also doesn't do
> what you want since I presume the "from employee" bit would mean you get
> many rows inserted into that temp table for all the existing data and not
> the one row you are operating on at the moment the trigger fires.
>
> It is worth noting also that if bulk operations are at all common for this
> table then writing this as an after statement trigger will likely be
> helpful for performance.
>
> For full context, we'd need to see how the function insert_info is defined.
>

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message aditya desai 2021-11-24 07:35:14 Re: Out of memory error
Previous Message Michael Lewis 2021-11-24 06:45:52 Re: Out of memory error