Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bCV04-00038T-Rz for pgsql-bugs@arkaria.postgresql.org; Mon, 13 Jun 2016 16:46:08 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bCV04-0001Ba-8r for pgsql-bugs@arkaria.postgresql.org; Mon, 13 Jun 2016 16:46:08 +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.84_2) (envelope-from ) id 1bCUzN-0000Rj-Oo for pgsql-bugs@postgresql.org; Mon, 13 Jun 2016 16:45:25 +0000 Received: from andy.depesz.com ([88.198.47.100] helo=depesz.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1bCUzA-0005q3-O9 for pgsql-bugs@postgresql.org; Mon, 13 Jun 2016 16:45:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=depesz.com; s=20140207; h=In-Reply-To:Content-Type:MIME-Version:References:Reply-To: Message-ID:Subject:Cc:To:Sender:From:Date:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=HVad/ucB0dMW5beWOifLsHNEke2F77N2th9KPYTx5Hk=; b=Mxv6UbsP2dyozOhTfE7HN7VItM qM6Jl9fQ0R06BwxjxYp5B3K3AZhVs6//g3vK6kx5UrBZdmnp9F5iMDT9zhss/zGTG4baCVBvMhP8l mRtGQBGq0kGhypA3268ZOIyz0; Received: from andy.depesz.com ([88.198.47.100] helo=depesz.com) by depesz.com with esmtpa (Exim 4.87) (envelope-from ) id 1bCUz7-0007yr-Uo; Mon, 13 Jun 2016 18:45:10 +0200 Date: Mon, 13 Jun 2016 18:45:09 +0200 From: hubert depesz lubaczewski To: Jeff Janes Cc: Pg Bugs Subject: Re: PostgreSQL (9.3 and 9.6) eats all memory when using many tables Message-ID: <20160613164509.GA26282@depesz.com> Reply-To: depesz@depesz.com References: <20160609154610.GA20600@depesz.com> <20160613093907.GA10381@depesz.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.0 (2016-04-01) X-Pg-Spam-Score: -3.4 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On Mon, Jun 13, 2016 at 09:27:40AM -0700, Jeff Janes wrote: > On Mon, Jun 13, 2016 at 2:39 AM, hubert depesz lubaczewski > wrote: > > On Sun, Jun 12, 2016 at 01:50:48PM -0700, Jeff Janes wrote: > > > > > Line #2 shows output of ps nh uww -p before start of work. > > There are, in total, 74002 tables, and then I iterate over list of them, > > and for each, I do the select I mentioned. > > > > Every 1000 tables, I get stats - ps output, and (in parent) sum of > > "Anonymous:" lines from /proc//smaps. > > > > As you can see - we're getting ~ 32kB of cache per table. > > What hardware and OS are you using? I only get a bit over 8kB per > table, and that amount doesn't change much between 9.3 and 9.6. These are 64bit aws virtual boxes (ec2, not rds) using ubuntu trusty. Pg is from ubuntu repo. > Can you share a representative table definition, including constraints? There are ~ 180 different tables, each looking different, and they are copied (schema, not data) across ~ 400 schemas. some tables have 1 index, some have up to 17. The 17 index table looks like this (sorry, had to redact it heavily): Column | Type | Modifiers --------------------------------------+-----------------------------+--------------------------------------------------------------------------- id | bigint | not null default nextval('...................................'::regclass) .... | character varying(255) | .......... | bigint | not null ...................... | character varying(255) | .............. | character varying(255) | not null .... | character varying(255) | ........ | timestamp without time zone | ........... | timestamp without time zone | ................... | bigint | ......... | boolean | ........................ | boolean | .......... | timestamp without time zone | .......... | timestamp without time zone | ............................ | boolean | ............. | text | ............................... | boolean | default false .......................... | character varying(255) | ....... | bigint | .............................. | boolean | default true ........... | character varying(255) | ............ | character varying(255) | default '....'::character varying .................. | bigint | ............... | bigint | not null .................. | bigint | not null ............. | character varying(255) | ............ | bigint | ............... | boolean | ............. | bigint | ................. | text | ................... | boolean | ................. | text | ............... | boolean | ....... | character varying(255) | ....... | boolean | .................................... | boolean | .................. | bigint | ...... | character varying(255) | ........ | text | ..................... | bigint | ................ | text | .................. | text | .................... | character varying(255) | ..................... | integer | .............. | character varying(255) | ......... | character varying(255) | .............. | character varying(255) | ........... | bigint | and on this there are 17 indexes, 7 fkeys, and it is being referenced by 15 other tables. Best regards, depesz -- The best thing about modern society is how easy it is to avoid contact with it. http://depesz.com/ -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs