pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How exactly PostgreSQL allocates memory for its needs?
3+ messages / 3 participants
[nested] [flat]

* How exactly PostgreSQL allocates memory for its needs?
@ 2010-02-10 05:10  Anton Maksimenkov <anton200@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Anton Maksimenkov @ 2010-02-10 05:10 UTC (permalink / raw)
  To: pgsql-performance

Can anybody briefly explain me how each postgres process allocate
memory for it needs?
I mean, what is the biggest size of malloc() it may want? How many
such chunks? What is the average size of allocations?

I think that at first it allocates contiguous piece of shared memory
for "shared buffers" (rather big, hundreds of megabytes usually, by
one chunk).
What next? temp_buffers, work_mem, maintenance_work_mem - are they
allocated as contiguous too?
What about other needs? By what size they are typically allocated?
-- 
antonvm



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: How exactly PostgreSQL allocates memory for its needs?
@ 2010-02-10 16:43  Justin Graf <justin@magwerks.com>
  parent: Anton Maksimenkov <anton200@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Justin Graf @ 2010-02-10 16:43 UTC (permalink / raw)
  To: pgsql-performance; anton200@gmail.com

On 2/10/2010 12:10 AM, Anton Maksimenkov wrote:
> Can anybody briefly explain me how each postgres process allocate
> memory for it needs?
> I mean, what is the biggest size of malloc() it may want? How many
> such chunks? What is the average size of allocations?
>
> I think that at first it allocates contiguous piece of shared memory
> for "shared buffers" (rather big, hundreds of megabytes usually, by
> one chunk).
> What next? temp_buffers, work_mem, maintenance_work_mem - are they
> allocated as contiguous too?
> What about other needs? By what size they are typically allocated?
>    

There  is no short answer to this, you should read section 18 of the manual
http://www.postgresql.org/docs/8.4/interactive/runtime-config.html
specifically section 18.4
http://www.postgresql.org/docs/8.4/interactive/runtime-config-resource.html

and performance section of the wiki
http://wiki.postgresql.org/wiki/Performance_Optimization

Here is a link annotated postgresql.conf
http://www.pgcon.org/2008/schedule/attachments/44_annotated_gucs_draft1.pdf

Keep in mind each connection/client that connecting to the server 
creates a new process on the server.  Each one the settings you list 
above is the max amount of memory each one of those sessions is allowed 
to consume.



All legitimate Magwerks Corporation quotations are sent in a .PDF file attachment with a unique ID number generated by our proprietary quotation system. Quotations received via any other form of communication will not be honored.

CONFIDENTIALITY NOTICE: This e-mail, including attachments, may contain legally privileged, confidential or other information proprietary to Magwerks Corporation and is intended solely for the use of the individual to whom it addresses. If the reader of this e-mail is not the intended recipient or authorized agent, the reader is hereby notified that any unauthorized viewing, dissemination, distribution or copying of this e-mail is strictly prohibited. If you have received this e-mail in error, please notify the sender by replying to this message and destroy all occurrences of this e-mail immediately.
Thank you.




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: How exactly PostgreSQL allocates memory for its needs?
@ 2010-02-11 03:46  Scott Marlowe <scott.marlowe@gmail.com>
  parent: Justin Graf <justin@magwerks.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Scott Marlowe @ 2010-02-11 03:46 UTC (permalink / raw)
  To: Justin Graf <justin@magwerks.com>; +Cc: pgsql-performance; anton200@gmail.com

On Wed, Feb 10, 2010 at 9:43 AM, Justin Graf <justin@magwerks.com> wrote:
> Keep in mind each connection/client that connecting to the server
> creates a new process on the server.  Each one the settings you list
> above is the max amount of memory each one of those sessions is allowed
> to consume.

It's even worse for work_mem (formerly sort_mem) in that each
individual hash agg or sort can grab that much memory.  A complex
query with 4 sorts and 2 hash aggregates could chew through 6 x
work_mem if it needed it.  Which is why work_mem can be such a
horrific foot gun.



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2010-02-11 03:46 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-02-10 05:10 How exactly PostgreSQL allocates memory for its needs? Anton Maksimenkov <anton200@gmail.com>
2010-02-10 16:43 ` Justin Graf <justin@magwerks.com>
2010-02-11 03:46   ` Scott Marlowe <scott.marlowe@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox