"shared_buffers" and "temp_buffers" why manual and code are different?

Started by Tianyin Xuover 12 years ago2 messagesgeneral
Jump to latest
#1Tianyin Xu
tixu@cs.ucsd.edu

Hi,

I want to tune the memory usage of PG (9.3.1) on my environment. I'm really
confused by the following two configuration parameters,

shared_buffers,
temp_buffers,

Take "shared_buffers" as the example, the manual says,

"Sets the amount of memory the database server uses for shared memory
buffers. The default is typically 128 megabytes (128MB), .... This setting
must be at least 128 kilobytes. "

However, when I look at the configuration code (below), the code shows it
should be the number of shared memory buffers *NOT* the size of the buffer
.

/* guc.c */
1638 {"shared_buffers", PGC_POSTMASTER, RESOURCES_MEM,
1639 gettext_noop("Sets the number of shared memory buffers
used by the server."),
1640 NULL,
1641 GUC_UNIT_BLOCKS
1642 },
1643 &NBuffers,
1644 1024, 16, INT_MAX / 2,
1645 NULL, NULL, NULL

So which one is correct?

Also, what exactly is the default value? The manual says that the default
is 128MB while the min is 128KB. But from the code, you can clearly see
that it's not the case.

Thank you very much!

Best regards,
Tianyin

--
Tianyin XU,
http://cseweb.ucsd.edu/~tixu/

#2Michael Paquier
michael@paquier.xyz
In reply to: Tianyin Xu (#1)
Re: "shared_buffers" and "temp_buffers" why manual and code are different?

On Sat, Nov 23, 2013 at 4:30 PM, Tianyin Xu <tixu@cs.ucsd.edu> wrote:

Hi,

I want to tune the memory usage of PG (9.3.1) on my environment. I'm really
confused by the following two configuration parameters,

shared_buffers,
temp_buffers,

Take "shared_buffers" as the example, the manual says,

"Sets the amount of memory the database server uses for shared memory
buffers. The default is typically 128 megabytes (128MB), .... This setting
must be at least 128 kilobytes. "

However, when I look at the configuration code (below), the code shows it
should be the number of shared memory buffers *NOT* the size of the buffer .

/* guc.c */
1638 {"shared_buffers", PGC_POSTMASTER, RESOURCES_MEM,
1639 gettext_noop("Sets the number of shared memory buffers used
by the server."),
1640 NULL,
1641 GUC_UNIT_BLOCKS
1642 },
1643 &NBuffers,
1644 1024, 16, INT_MAX / 2,
1645 NULL, NULL, NULL

So which one is correct?

Both. The GUC parameter uses as input the physical size of shared
buffers given by postgresql.conf, then converts it internally to the
number of shared buffers, number calculated depending on BLCKSZ. All
the calculation is done in guc.c:parse_int.

Also, what exactly is the default value? The manual says that the default is
128MB while the min is 128KB. But from the code, you can clearly see that
it's not the case.

There is no exact default value. The default is usually 128MB, but it
can be lower depending of what initdb decides.
Regards,
--
Michael

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general