Re: Sort memory not being released - Mailing list pgsql-general

From Tom Lane
Subject Re: Sort memory not being released
Date
Msg-id 15659.1055885916@sss.pgh.pa.us
Whole thread Raw
In response to Re: Sort memory not being released  ("Jim C. Nasby" <jim@nasby.net>)
Responses Re: Sort memory not being released  ("Jim C. Nasby" <jim@nasby.net>)
List pgsql-general
"Jim C. Nasby" <jim@nasby.net> writes:
> Of course I wasn't planning on sucking down a bunch of memory and
> holding on to it. :)

Sure.  But when you're done with the big sort, just start a fresh
session.  I don't see that this is worth agonizing over.

> If sort_mem is over X size, then use only Y for pre-buffering (How much
> does a large sort_mem help if you have to spill to disk?)

It still helps quite a lot, because the average initial run length is
(if I recall Knuth correctly) twice the working buffer size.  I can't
see a reason for cutting back usage once you've been forced to start
spilling.

The bigger problem with your discussion is the assumption that we can
find out "if the OS is running low on free physical memory".  That seems
(a) unportable and (b) a moving target.

            regards, tom lane

pgsql-general by date:

Previous
From: "Jim C. Nasby"
Date:
Subject: Re: order of nested loop
Next
From: Joseph Shraibman
Date:
Subject: Re: order of nested loop