Обсуждение: Total memory allocated to postgres

Поиск
Список
Период
Сортировка

Total memory allocated to postgres

От
vamsi krishna
Дата:
Hi
 
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?
 
OR
 
do I need to change some parameter in postgresql.conf file in data directory in pgsql folder?
 
Thanks
Vamsi
 
 

Re: Total memory allocated to postgres

От
Robert Haas
Дата:
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