Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ecE8Y-0006Wb-MK for pgsql-admin@arkaria.postgresql.org; Thu, 18 Jan 2018 17:38:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ecE8Y-0005x0-9u for pgsql-admin@arkaria.postgresql.org; Thu, 18 Jan 2018 17:38:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ecE8Y-0005wr-3B for pgsql-admin@lists.postgresql.org; Thu, 18 Jan 2018 17:38:02 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ecE8V-00022s-Eg for pgsql-admin@lists.postgresql.org; Thu, 18 Jan 2018 17:38:01 +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 w0IHbvdb007977; Thu, 18 Jan 2018 12:37:57 -0500 From: Tom Lane To: Davlet Panech cc: pgsql-admin@lists.postgresql.org Subject: Re: Abnormally high memory usage/OOM triggered In-reply-to: <15a90b55-5151-ce22-16ee-7ff883e5eb97@gmail.com> References: <4d52fee7-73ba-16a9-9c27-8ae5107ee6ae@gmail.com> <5E0AB8DB-F13B-41BF-843A-FE64FBE9C097@elevated-dev.com> <15a90b55-5151-ce22-16ee-7ff883e5eb97@gmail.com> Comments: In-reply-to Davlet Panech message dated "Thu, 18 Jan 2018 12:13:33 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <7975.1516297077.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 18 Jan 2018 12:37:57 -0500 Message-ID: <7976.1516297077@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Davlet Panech writes: > On 1/17/2018 5:57 PM, scott ribe wrote: >> It does seem awfully high, but... An update can involve a join across m= ultiple tables. Or an update can run a trigger which can cascade. Either o= f those could result in an "accidental cross product" join, which can alwa= ys blow up memory. > There must be a way to put an upper limit on memory even for such cases.= = > I was under the impression that parameters such as "work_mem" serve that= = > purpose, is that not the case? So an "accidental cross product" join's = > memory usage is unbounded? It can't be... could somebody confirm this = > please? A large join result could blow out memory on the client side, unless the client is careful to read it in segments, which most clients aren't. I expect the server to be smarter though. regards, tom lane