Re: Postgres 10.3 delete on partition table cannot execute, out ofmemory. - Mailing list pgsql-bugs

From Amit Langote
Subject Re: Postgres 10.3 delete on partition table cannot execute, out ofmemory.
Date
Msg-id fecdef72-8c2a-0794-8e0a-2ad76db82c68@lab.ntt.co.jp
Whole thread Raw
In response to Postgres 10.3 delete on partition table cannot execute, out of memory.  (Mark Magnus <mark.magnus@impactdata.com.au>)
List pgsql-bugs
Hi.

On 2018/03/15 13:15, Mark Magnus wrote:
> Bug
> 
> Partitioned table has 7202 partitions. No partition contains more than 50
> records. Partitioning is done on a foreign key. Any delete operation i.e.
> "delete from contacts where id = ?" or
> "delete from contacts where id = ? and account_id = ?" or
> "delete from contacts where account_id = ?"
> results in out of memory condition.
> 
> Default Postgres Configuration with exception
> max_locks_per_transaction = 1024

As Fabio says, it seems most likely that OOM was triggered while planning
the delete operation.  I can reproduce OOM being triggered on my modest
development machine, so perhaps that's what's happening in your case too.

This is unfortunately expected, given that the underlying planning
mechanism cannot cope beyond a few hundred partitions. :-(  See a relevant
note in the documentation; last line of the page at this link:
https://www.postgresql.org/docs/devel/static/ddl-partitioning.html.

Until things improve in that area, one workaround might be to perform the
delete operation directly on the partition, as it's possible to do that.
Or redesign your schema to use less number of partitions.

Thanks,
Amit



pgsql-bugs by date:

Previous
From: Andres Freund
Date:
Subject: Re: BUG #15114: logical decoding Segmentation fault
Next
From: alertas
Date:
Subject: Re: BUG #15108: Initialization problem postgresql-10-setup initdb