pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: psuderevsky@gmail.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #14078: Excessive memory growth during nested loop in select
Date: Tue, 12 Apr 2016 17:15:39 -0400
Message-ID: <5559.1460495739@sss.pgh.pa.us> (raw)
In-Reply-To: <20160408163736.15196.33214@wrigleys.postgresql.org>
References: <20160408163736.15196.33214@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

psuderevsky@gmail.com writes:
> [ query producing a 46-million-row join result ]

> Observing amount of memory consumed by psql process with pmap utility...
> So about 8Gb of linux virtual memory has been allocated for join of two
> tables with sizes of 11MB.
> The question is why so high amount of virtual memory is consumed, isn't it
> a memory leak.

No, it's just a very large query result.  psql collects the entire query
result into memory before printing any of it, so that it can format the
result nicely.  If you're dealing with query results large enough for that
to be a problem, you could consider using psql's FETCH_COUNT variable to
make it fetch and format a smaller number of rows at a time; which would
trade off the niceness of the formatting for less memory usage.

			regards, tom lane


-- 
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 (2+ messages)

Message-ID: <5559.1460495739@sss.pgh.pa.us>
Permalink:  ../5559.1460495739@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/5559.1460495739@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, psuderevsky@gmail.com
  Subject: Re: BUG #14078: Excessive memory growth during nested loop in select
  In-Reply-To: <5559.1460495739@sss.pgh.pa.us>
  References: <20160408163736.15196.33214@wrigleys.postgresql.org> <5559.1460495739@sss.pgh.pa.us>

* 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