Re: Work Mem Allocation Questions

From: Bill Moran <wmoran(at)potentialtech(dot)com>
To: Brad Nicholson <bnichols(at)ca(dot)afilias(dot)info>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Work Mem Allocation Questions
Date: 2010-03-03 16:48:35
Message-ID: 20100303114835.7f8f223f.wmoran@potentialtech.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

In response to Brad Nicholson <bnichols(at)ca(dot)afilias(dot)info>:

> 1: Is the default work_mem pre-allocated to the Postgres processes - or
> does it get allocated when needed? Say I have work_mem at 30MB - will
> Postgres allocate that 30MB on connection, or only when it needed by a
> query?

It's allocated on demand and freed when no longer needed.

> 2: If work_mem is, say, 30MB, and my query needs 10MB - will Postgres
> allocate all 30MB, or just the 10MB I need?

Same answer.

Keep in mind that work_mem is not an upper cap, it is a per-sort limit.
Thus a query with 5 sorts could allocate 5 * work_mem. The docs have
a little more detail on this.

--
Bill Moran
http://www.potentialtech.com
http://people.collaborativefusion.com/~wmoran/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Brendan Jurd 2010-03-03 16:51:14 Re: [GENERAL] to_timestamp() and quarters
Previous Message Terry 2010-03-03 16:45:07 Re: finding duplicate numbers in a select distinct statement