Re: Changing work_mem

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: rihad <rihad(at)mail(dot)ru>, Luca Ferrari <fluca1978(at)gmail(dot)com>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, pgsql-general General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Changing work_mem
Date: 2019-08-14 07:42:48
Message-ID: 46a5322e766fddb15cae66b4ec852289379ef75e.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

rihad wrote:
> > Sorry, I just decreased work_mem back to 256MB, reloaded, and
> > instantly started seeing 82mb temp file creation, not 165mb as was
> > usual with work_mem=512MB.
> >
> > So it indeed was applied immediately.
> > Really weird figures )
>
> Increased work_mem to 768MB and start seeing temp file creation log
> entries 331MB in size.
>
> Bizzare ) It looks like the bigger it gets, the bigger temp files
> are
> created.
>
> Why not decrease it to 64mb then...

Temporary files are created whenever the data is estimated to not
fit into "work_mem". So it is unsurprising that you see bigger
temporary files being created if you increase "work_mem".

Big temporary files will also be created when "work_mem" is small,
but maybe they got lost in the noise of the smaller files.
You should have noticed that fewer files are created when you increase
"work_mem".

Another thing to notice is that the temporary files use another, more
compact format than the data in memory, so you need to increase
"work_mem" to more than X if you want to avoid temporary files
of size X.

Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message rihad 2019-08-14 08:40:20 Re: Changing work_mem
Previous Message Luca Ferrari 2019-08-14 07:32:56 Re: Question on pgwatch