From: | Mark Kirkwood <mark(dot)kirkwood(at)catalyst(dot)net(dot)nz> |
---|---|
To: | Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>, "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com> |
Cc: | Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: How to reduce writing on disk ? (90 gb on pgsql_tmp) |
Date: | 2015-06-04 01:19:44 |
Message-ID: | 556FA7B0.6050108@catalyst.net.nz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On 04/06/15 12:58, Scott Marlowe wrote:
> On Wed, Jun 3, 2015 at 6:53 PM, Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com> wrote:
>> On Wed, Jun 3, 2015 at 4:29 PM, Joshua D. Drake <jd(at)commandprompt(dot)com> wrote:
>>>
>>> On 06/03/2015 03:16 PM, Tomas Vondra wrote:
>>>
>>>> What is more important, though, is the amount of memory. OP reported the
>>>> query writes ~95GB of temp files (and dies because of full disk, so
>>>> there may be more). The on-disk format is usually more compact than the
>>>> in-memory representation - for example on-disk sort often needs 3x less
>>>> space than in-memory qsort. So we can assume the query needs >95GB of
>>>> data. Can you explain how that's going to fit into the 64GB RAM?
>>>>
>>>>> Cache is free memory. If you think of it any other way when you're
>>>>> looking at memory usage and pressure on theings like swap you're
>>>>> gonna make some bad decisions.
>>>>
>>>>
>>>> Cache is not free memory - it's there for a purpose and usually plays a
>>>> significant role in performance. Sure, it may be freed and used for
>>>> other purposes, but that has consequences - e.g. it impacts performance
>>>> of other queries etc. You generally don't want to do that on production.
>>>
>>>
>>> Exactly. If your cache is reduced your performance is reduced because less
>>> things are in cache. It is not free memory. Also the command "free" is not
>>> useful in this scenario. It is almost always better to use sar so you can
>>> see where the data points are that free is using.
>>
>> But if that WAS happening he wouldn't still HAVE 60G of cache! That's
>> my whole point. He's NOT running out of memory. He's not even having
>> to dump cache right now.
>
> Further if he started using a few gig here for this one it wouldn't
> have a big impact on cache (60G-1G etc) but might make it much faster,
> as spilling to disk is a lot less intrusive when you've got a bigger
> chunk of ram to work in. OTOH doing something like setting work_mem to
> 60G would likely be fatal.
>
> But he's not down to 3GB of memory by any kind of imagination. Any
> working machine will slowly, certainly fill its caches since it's not
> using the memory for anything else. That's normal. As long as you're
> not blowing out the cache you're fine.
>
>
I agree with Scott's analysis here.
It seems to me that the issue is the query(s) using too much disk space.
As others have said, it may not be practical to up work_mem to the point
where is all happens in memory...so probably need to:
- get more disk or,
- tweak postgres params to get a less disk hungry plan (need to see that
explain analyze)!
Cheers
Mark
From | Date | Subject | |
---|---|---|---|
Next Message | Graeme B. Bell | 2015-06-04 11:07:39 | Need more IOPS? This should get you drooling... (5xnvme drives) |
Previous Message | Scott Marlowe | 2015-06-04 00:58:52 | Re: How to reduce writing on disk ? (90 gb on pgsql_tmp) |