Re: [GENERAL] Out of memory/corrupted shared memory problem on server - Mailing list pgsql-general

From Tom Lane
Subject Re: [GENERAL] Out of memory/corrupted shared memory problem on server
Date
Msg-id 32546.1504007313@sss.pgh.pa.us
Whole thread Raw
In response to Re: [GENERAL] Out of memory/corrupted shared memory problem on server  (Johann Spies <johann.spies@gmail.com>)
List pgsql-general
Johann Spies <johann.spies@gmail.com> writes:
> On 25 August 2017 at 13:48, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Remember that "work_mem" is "work memory per plan node", so a complex
>> query could easily chew up a multiple of that number --- and that's
>> with everything going according to plan.  If, say, the planner
>> underestimates the number of table entries involved in a hash
>> aggregation, the actual consumption might be much larger.

> The main source of this query (doing a lot of calculations) is another
> Materialized View
> with more than 700 million records. I then analyzed that MV and this
> morning the good news was:

> # REFRESH MATERIALIZED VIEW wos_2017_1.citation_window_mv ;
> REFRESH MATERIALIZED VIEW
> Time: 27128469.899 ms

OK, so almost certainly the crash was caused by a hash aggregate
using so much memory that it triggered the OOM killer.  Whether
a hash aggregate's hashtable will stay within work_mem is dependent
on whether the planner correctly predicts the number of entries needed.
Analyzing the input MV must have improved that estimate and led the
planner to choose some other plan.

            regards, tom lane


pgsql-general by date:

Previous
From: Michael Paquier
Date:
Subject: Re: [GENERAL] Unlogged Crash Detection
Next
From: Stuart Bishop
Date:
Subject: Re: [GENERAL] Create Action for psql when NOTIFY Recieved