Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eK3er-0001Qs-4e for pgsql-bugs@arkaria.postgresql.org; Wed, 29 Nov 2017 14:48:17 +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 1eK3eq-000528-Fp for pgsql-bugs@arkaria.postgresql.org; Wed, 29 Nov 2017 14:48:16 +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 1eK3eq-0004uH-A7 for pgsql-bugs@lists.postgresql.org; Wed, 29 Nov 2017 14:48:16 +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 1eK3ei-0003EJ-W1 for pgsql-bugs@postgresql.org; Wed, 29 Nov 2017 14:48:15 +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 vATEm6xS029533; Wed, 29 Nov 2017 09:48:06 -0500 From: Tom Lane To: maxim.boguk@gmail.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #14936: Huge backend memory usage during schema dump of database with many views In-reply-to: <20171129100649.1473.73990@wrigleys.postgresql.org> References: <20171129100649.1473.73990@wrigleys.postgresql.org> Comments: In-reply-to maxim.boguk@gmail.com message dated "Wed, 29 Nov 2017 10:06:49 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <29531.1511966886.1@sss.pgh.pa.us> Date: Wed, 29 Nov 2017 09:48:06 -0500 Message-ID: <29532.1511966886@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk maxim.boguk@gmail.com writes: > I got off-list report of the following issue: > server used all memory and crash with OOM during pg_dump of the database > with many schemes and views. > After removing all extra stuff problem can be show with simple run the > following query on the database: > select (CASE WHEN pg_has_role(c.relowner, 'USAGE'::text) THEN > pg_get_viewdef(c.oid) ELSE NULL::text END) as view_src from pg_class c where > (c.relkind = 'v'::"char"); Hm. It's certainly no surprise if pg_get_viewdef eats memory, but why wouldn't it get reclaimed at the end of each tuple cycle? Also: I don't think the above query is very representative of what pg_dump actually does; AFAIR it pulls view definitions one at a time, not all at once. That leads me to guess that what's going on is relcache bloat, since relcache entries would persist across queries. There's no mechanism for limiting the number of entries in that cache. regards, tom lane