Re: memory explosion on planning complex query

From: Tomas Vondra <tv(at)fuzzy(dot)cz>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: memory explosion on planning complex query
Date: 2014-11-26 22:40:52
Message-ID: 547656F4.20209@fuzzy.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 26.11.2014 23:26, Peter Geoghegan wrote:
> On Wed, Nov 26, 2014 at 2:00 PM, Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:
>> The client's question is whether this is not a bug. It certainly seems like
>> it should be possible to plan a query without chewing up this much memory,
>> or at least to be able to limit the amount of memory that can be grabbed
>> during planning. Going from humming along happily to OOM conditions all
>> through running "explain <somequery>" is not very friendly.
>
>
> Have you tried this with a "#define SHOW_MEMORY_STATS" build, or
> otherwise rigged Postgres to call MemoryContextStats() at interesting
> times?

FWIW, this does the trick on a regular build:

gdb -batch -x gdb.cmd -p $PID

where gdb.cmd is a file with a single line:

p MemoryContextStats(TopMemoryContext)

Just execute it at the interesting moment when a lot of memory is consumed.

Tomas

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Antonin Houska 2014-11-26 22:41:24 Re: memory explosion on planning complex query
Previous Message Tomas Vondra 2014-11-26 22:26:34 Re: BUG #12071: Stat collector went crasy (50MB/s constant writes)