Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1krPuA-0008C6-Fn for pgsql-bugs@arkaria.postgresql.org; Mon, 21 Dec 2020 18:27:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1krPu9-000485-Dx for pgsql-bugs@arkaria.postgresql.org; Mon, 21 Dec 2020 18:27:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1krPu9-00047v-82 for pgsql-bugs@lists.postgresql.org; Mon, 21 Dec 2020 18:27:33 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1krPu3-0006hD-3P for pgsql-bugs@lists.postgresql.org; Mon, 21 Dec 2020 18:27:32 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 0BLIRPut543676; Mon, 21 Dec 2020 13:27:26 -0500 From: Tom Lane To: Konstantin Knizhnik cc: pgsql-bugs@lists.postgresql.org Subject: Re: Large objects and out-of-memory In-reply-to: <7c57860c-fc05-143e-aa81-f11ca13ec00a@postgrespro.ru> References: <7c57860c-fc05-143e-aa81-f11ca13ec00a@postgrespro.ru> Comments: In-reply-to Konstantin Knizhnik message dated "Mon, 21 Dec 2020 19:33:42 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <543674.1608575245.1@sss.pgh.pa.us> Date: Mon, 21 Dec 2020 13:27:25 -0500 Message-ID: <543675.1608575245@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Konstantin Knizhnik writes: > The following sequence of command cause backend's memory to exceed 10Gb: > INSERT INTO image1 SELECT lo_creat(-1) FROM generate_series(1,10000000); > REASSIGN OWNED BY alice TO testlo; [ shrug... ] You're asking to change the ownership of 10000000 objects. This is not going to be a cheap operation. AFAIK it's not going to be any more expensive than changing the ownership of 10000000 tables, or any other kind of object. The argument for allowing large objects to have per-object ownership and permissions in the first place was that useful scenarios wouldn't have a huge number of them (else you'd run out of disk space, if they're actually "large"), so we needn't worry too much about the overhead. We could possibly bound the amount of space used in the inval queue by switching to an "invalidate all" approach once we got to an unreasonable amount of space. But this will do nothing for the other costs involved, and I'm not really sure it's worth adding complexity for. regards, tom lane