postgresql 12 runs out of memory when updating a partitioned table with subquery

Поиск
Список
Период
Сортировка
От Max Vikharev
Тема postgresql 12 runs out of memory when updating a partitioned table with subquery
Дата
Msg-id CACRpr1NaU8x_+y63RfBf2QzZJVPPqR-xWcV9WjAgPzDOe6rkUg@mail.gmail.com
обсуждение исходный текст
Ответы Re: postgresql 12 runs out of memory when updating a partitioned table with subquery  (David Rowley <dgrowleyml@gmail.com>)
Список pgsql-bugs
Hi,

I have 'out of mem' on postgresql 12 when updating a partitioned table with subquery.
I have Project and Content relations. Content is partitioned by type and subpartitioned by project.

When I update content of some type of a single project with subquery - postgresql query hangs and runs out of mem. 

Test env has the following settings:
1. 4G RAM, 2 CPU.
2. Ubuntu 16.04
3. Default postgresql settings (details in link https://gist.github.com/mvikharev/f770914a8bb7f814c5aab4fd1da109f7#file-configuration)
4. 100 rows in 100 subpartitions for 2 partitions.

Scripts to reproduce the problem

Reproduce
1. Create schema 
createdb test
./schema.sh > schema.sql
./data.sh > data.sql
psql test < schema.sql
psql test < data.sql

2. Update with prepared ids - no problem
SELECT id into agg
FROM "content"
WHERE "content"."id" IN
    (SELECT U0."id" AS Col1
     FROM "content" U0
     INNER JOIN "project" U2 ON (U0."project_id" = U2."id")
     WHERE (U0."service_id" = 2
            AND U0."type_id" = 0
            AND U2."user_id" = 1));
SELECT 1000

UPDATE "content"
SET "value" = '1'
WHERE "content"."id" IN (select id from agg);
UPDATE 1000

3. Update with subquery - out of mem
UPDATE "content"
SET "value" = '1'
WHERE "content"."id" IN
    (SELECT U0."id" AS Col1
     FROM "content" U0
     INNER JOIN "project" U2 ON (U0."project_id" = U2."id")
     WHERE (U0."service_id" = 2
            AND U0."type_id" = 0
            AND U2."user_id" = 1));

^CCancel request sent
^CCancel request sent
^CCancel request sent
^CCancel request sent
^CCancel request sent
server closed the connection unexpectedly

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

Предыдущее
От: legrand legrand
Дата:
Сообщение: Re: BUG #16535: Implementing Autonomous Transactions in Postgresql
Следующее
От: David Rowley
Дата:
Сообщение: Re: postgresql 12 runs out of memory when updating a partitioned table with subquery