Re: Multiple sorts in a query - Mailing list pgsql-hackers

From Martijn van Oosterhout
Subject Re: Multiple sorts in a query
Date
Msg-id 20090519114407.GB6215@svana.org
Whole thread Raw
In response to Multiple sorts in a query  (Simon Riggs <simon@2ndQuadrant.com>)
Responses Re: Multiple sorts in a query  (Merlin Moncure <mmoncure@gmail.com>)
List pgsql-hackers
On Tue, May 19, 2009 at 12:32:13PM +0100, Simon Riggs wrote:
> If we allocate large chunks of memory we use malloc(). So complex
> queries can have multiple mallocs, followed by multiple reallocs. That
> in itself seems likely to end up with roughly double memory use, since
> realloc won't work properly/quickly with multiple mallocs. (Double since
> we allocate X bytes, then 2X bytes etc until we hit the limit.)

I don't know about Solaris, but glibc has a threshold above which it
starts using mmap() instead of sbrk(). Thus, once you start using very
large blocks, freeing always returns the memory to the kernel,
irrespective of other allocations.

The threshold is dynamic apparently, but starts at 128KB.

Just a thought,

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Multiple sorts in a query
Next
From: Simon Riggs
Date:
Subject: Re: Multiple sorts in a query