Query planning on partitioned table causes postgres 13.4 to consume all memory

From: Duncan Sands <duncan(dot)sands(at)deepbluecap(dot)com>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Query planning on partitioned table causes postgres 13.4 to consume all memory
Date: 2021-09-17 09:49:06
Message-ID: 4a3115d4-0fb2-e214-93e3-9a9d0974b883@deepbluecap.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Postgresql version: 13.4
O/S version: Ubuntu 21.04

How to reproduce:
(1) Create "data" schema and its tables by executing the commands from the
attached file d.sql. Each of the two created tables has less than 20 rows.
(2) Execute or EXPLAIN this query

DELETE FROM data.files

WHERE path=ANY(

SELECT path

FROM (

SELECT meta, path,

first_value(path)

OVER (PARTITION BY meta ORDER BY priority) AS first

FROM data.files

) f,

data.metadata m

WHERE f.path <> f.first

AND f.meta = m.id

AND m.syd = 667

);

(3) Observe that the EXPLAIN/query never completes, and memory usage goes up
and up.

For example:

duncan=> \i /tmp/d.sql

...
duncan=> DELETE FROM data.files

WHERE path=ANY(

SELECT path

FROM (

SELECT meta, path,

first_value(path)

OVER (PARTITION BY meta ORDER BY priority) AS first

FROM data.files

) f,

data.metadata m

WHERE f.path <> f.first

AND f.meta = m.id

AND m.syd = 667

);

... wailing and gnashing of teeth ...

Attachment Content-Type Size
d.sql application/sql 1008.3 KB

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Дмитрий Секретов 2021-09-17 11:13:43 Re: BUG #17070: Sometimes copy from ingnores transaction
Previous Message Sushant Kamboj 2021-09-16 12:36:02 Re: BUG #17193: Issue with pg_output login