Re: Total memory allocated to postgres - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Total memory allocated to postgres
Date
Msg-id AANLkTimweHoa6c6kDEH4x0R2_PSo6W+5xkEKbAyiCJmc@mail.gmail.com
Whole thread Raw
In response to Total memory allocated to postgres  (vamsi krishna <vamsikrishna1902@gmail.com>)
List pgsql-hackers
On Fri, Oct 8, 2010 at 10:37 AM, vamsi krishna
<vamsikrishna1902@gmail.com> wrote:
> I want to know how much main memory  is actually allocated to be the maximum
> memory for postgresql, because my hardware may have 4GB main memory but at
> the end of the day, only 1GB may be allocated for postgres.
>
> I want to set (increase) it manually. Can someone tell me how to do it?
>
> In aset.c we have a function
> AllocSetContextCreate(MemoryContext parent,const char *name,Size
> minContextSize,Size initBlockSize,Size maxBlockSize) defn.
>
> maxBlockSize is initialized to 8MB in mcxt.c where AllocSetContextCreate()
> is called. If I increase this value to 80 MB or so, will it increase the
> memory allocated to postgresql or will it just increase the block size?

That's not going to work.

> OR
>
> do I need to change some parameter in postgresql.conf file in data directory
> in pgsql folder?

The total amount of memory used by postgresql isn't something that you
can easily control exactly.  The two configuration variables that have
the most impact on it are shared_buffers and work_mem.  See
http://www.postgresql.org/docs/current/static/runtime-config-resource.html#RUNTIME-CONFIG-RESOURCE-MEMORY

Keep in mind that PostgreSQL relies on the system buffer cache to some
degree.  You may need to play around with the parameters a bit to see
what makes your system work best.  I wouldn't focus so much on
measuring memory usage as looking at whether everything you have
running on the machine is running well and giving decent performance.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: getting set up on git (finally)
Next
From: Simon Riggs
Date:
Subject: Re: Sync Replication with transaction-controlled durability