Re: Out of memory error

Поиск
Список
Период
Сортировка
От Thomas Kellerer
Тема Re: Out of memory error
Дата
Msg-id f8952c15-6cde-2a0a-b095-cfedd34ba734@gmx.net
обсуждение исходный текст
Ответ на Re: Out of memory error  (aditya desai <admad123@gmail.com>)
Список 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;






В списке pgsql-performance по дате отправления:

Предыдущее
От: Thomas Kellerer
Дата:
Сообщение: Re: Out of memory error
Следующее
От: Tomas Vondra
Дата:
Сообщение: Re: Postgres process count GCC vs Clang is Different on autovaccum=on