Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ewhzE-0005fh-Pp for pgsql-bugs@arkaria.postgresql.org; Fri, 16 Mar 2018 05:33:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ewhzD-0003Qr-7j for pgsql-bugs@arkaria.postgresql.org; Fri, 16 Mar 2018 05:33:03 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ewhzC-0003Qh-Ul for pgsql-bugs@lists.postgresql.org; Fri, 16 Mar 2018 05:33:03 +0000 Received: from tama500.ecl.ntt.co.jp ([129.60.39.148]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ewhz8-0001ma-Pc for pgsql-bugs@postgresql.org; Fri, 16 Mar 2018 05:33:01 +0000 Received: from vc1.ecl.ntt.co.jp (vc1.ecl.ntt.co.jp [129.60.86.153]) by tama500.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id w2G5WtRS031975; Fri, 16 Mar 2018 14:32:55 +0900 Received: from vc1.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id 2237EEA80AF; Fri, 16 Mar 2018 14:32:55 +0900 (JST) Received: from jcms-pop21.ecl.ntt.co.jp (jcms-pop21.ecl.ntt.co.jp [129.60.87.134]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id 17BF3EA7F56; Fri, 16 Mar 2018 14:32:55 +0900 (JST) Received: from [127.0.0.1] (unknown [129.60.241.61]) by jcms-pop21.ecl.ntt.co.jp (Postfix) with ESMTPSA id 11EFD400B0B; Fri, 16 Mar 2018 14:32:55 +0900 (JST) Subject: Re: Postgres 10.3 delete on partition table cannot execute, out of memory. References: From: Amit Langote Message-ID: Date: Fri, 16 Mar 2018 14:32:44 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CC-Mail-RelayStamp: 1 To: Mark Magnus , pgsql-bugs@postgresql.org X-TM-AS-MML: disable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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