pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: hubert depesz lubaczewski <depesz@depesz.com>
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: PostgreSQL (9.3 and 9.6) eats all memory when using many tables
Date: Mon, 13 Jun 2016 15:22:17 +0200
Message-ID: <20160613132216.GA31472@depesz.com> (raw)
In-Reply-To: <41f45186-64f6-8f9a-c72a-a3e9555d57b1@2ndquadrant.com>
References: <20160609154610.GA20600@depesz.com>
	<41f45186-64f6-8f9a-c72a-a3e9555d57b1@2ndquadrant.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

On Mon, Jun 13, 2016 at 08:56:56AM -0400, Peter Eisentraut wrote:
> On 6/9/16 11:46 AM, hubert depesz lubaczewski wrote:
> > Basically it looks that postgresql "caches" query plans? parsed elements? for
> > queries, but doesn't put any kind of limit to size of this cache. Which means
> > that if our app is using LOTS of different queries, the memory usage will grow
> > in time.
> 
> If you compile with -DSHOW_MEMORY_STATS, it will print out memory allocation
> after every command, so you might be able to see where the memory is going.

Compiled, am running it now, but it is much slower now. And the output
is huge.

After ~5k queries, it looks like:
TopMemoryContext: 5892000 total in 701 blocks; 18344 free (68 chunks); 5873656 used
  TableSpace cache: 8192 total in 1 blocks; 3216 free (0 chunks); 4976 used
  Operator lookup cache: 24576 total in 2 blocks; 11888 free (5 chunks); 12688 used
  MessageContext: 32768 total in 3 blocks; 6216 free (5 chunks); 26552 used
  Operator class cache: 8192 total in 1 blocks; 1680 free (0 chunks); 6512 used
  smgr relation table: 4186112 total in 9 blocks; 1374144 free (31 chunks); 2811968 used
  TransactionAbortContext: 32768 total in 1 blocks; 32736 free (0 chunks); 32 used
  Portal hash: 8192 total in 1 blocks; 1680 free (0 chunks); 6512 used
  PortalMemory: 8192 total in 1 blocks; 8160 free (1 chunks); 32 used
  Relcache by OID: 2088960 total in 8 blocks; 1008496 free (16 chunks); 1080464 used
  CacheMemoryContext: 182443144 total in 422 blocks; 2623776 free (1 chunks); 179819368 used
  MdSmgr: 1040384 total in 7 blocks; 192512 free (0 chunks); 847872 used
  ident parser context: 3072 total in 2 blocks; 1416 free (1 chunks); 1656 used
  hba parser context: 130048 total in 7 blocks; 42496 free (2 chunks); 87552 used
  LOCALLOCK hash: 24576 total in 2 blocks; 13920 free (4 chunks); 10656 used
  Timezones: 83472 total in 2 blocks; 3744 free (0 chunks); 79728 used
  ErrorContext: 8192 total in 1 blocks; 8160 free (6 chunks); 32 used

I'll try to get to the end of the test (~70k tables), and then show the
same info, plus some statistics about "CacheMemoryContext" if it helps
(I'd rather not show *all* of it, though :)

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



view thread (13+ messages)  latest in thread

Message-ID: <20160613132216.GA31472@depesz.com>
Permalink:  ../20160613132216.GA31472@depesz.com/
Also on:    postgresql.org/message-id/20160613132216.GA31472@depesz.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: depesz@depesz.com, peter.eisentraut@2ndquadrant.com
  Subject: Re: PostgreSQL (9.3 and 9.6) eats all memory when using many tables
  In-Reply-To: <20160613132216.GA31472@depesz.com>
  References: <20160609154610.GA20600@depesz.com> <41f45186-64f6-8f9a-c72a-a3e9555d57b1@2ndquadrant.com> <20160613132216.GA31472@depesz.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox