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 1f1JHR-0001H7-VE for pgsql-general@arkaria.postgresql.org; Wed, 28 Mar 2018 22:10:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f1JHQ-0002r6-Sk for pgsql-general@arkaria.postgresql.org; Wed, 28 Mar 2018 22:10:52 +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 1f1JHQ-0002qv-HK for pgsql-general@lists.postgresql.org; Wed, 28 Mar 2018 22:10:52 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f1JHO-0001L0-7h for pgsql-general@postgresql.org; Wed, 28 Mar 2018 22:10:51 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w2SMAmo8025196; Wed, 28 Mar 2018 18:10:48 -0400 From: Tom Lane To: Cory Tucker cc: "pgsql-general@postgresql.org" Subject: Re: Query Crashes PG 10.3 using partitions, works on 9.6 In-reply-to: References: Comments: In-reply-to Cory Tucker message dated "Wed, 28 Mar 2018 21:49:16 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <25194.1522275048.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 28 Mar 2018 18:10:48 -0400 Message-ID: <25195.1522275048@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Cory Tucker writes: > I was issuing a query on both databases to cleanup some duplicates in > preparation of applying new indexes. On the 9.6 database with all the d= ata > in one table, the query runs fine in about 6 min. On 10.3, with a work_= mem > setting of 1GB the query runs for about 7 minutes and then gets terminat= ed > with an out of memory error. Hm, this seems a bit excessive: MessageContext: 1333788672 total in 169 blocks; 2227176 free (9 chunks);= 1331561496 used and this is really grim: 65678 more child contexts containing 47607478048 total in 2577 blo= cks; 12249392 free (446 chunks); 47595228656 used and this is just silly: 2018-03-28 19:20:33.264 UTC [10580] cory@match ERROR: out of memory 2018-03-28 19:20:33.264 UTC [10580] cory@match DETAIL: Failed on request = of size 1610612736. Can you extract a self-contained test case that uses unreasonable amounts of memory? It seems from this trace that the wheels are coming off in at least two places, but identifying exactly where is impossible without more info. If you can't make a publishable test case, capturing a stack trace from the point of the OOM error (set the breakpoint at errfinish) would probably be enough info to figure out what is trying to grab 1.6GB in one bite. But it won't help us find out why so many empty ExprContexts are getting created. regards, tom lane