Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the unit of PostgreSQL shared_buffers?

Tags:

postgresql

I want to change mu pgsql database config and I wonder what units they use there to describe some values. Mostly I want to know about shared_buffers.

If my shared_buffers value is for example 16384, is it KB? MB? Bytes? What is the unit of this value?

like image 779
b4rt3kk Avatar asked Jul 03 '14 08:07

b4rt3kk


People also ask

What is shared_buffers PostgreSQL?

shared_buffers (integer) Sets the amount of memory the database server uses for shared memory buffers. The default is typically 32 megabytes (32MB), but might be less if your kernel settings will not support it (as determined during initdb). This setting must be at least 128 kilobytes.

What is effective cache size in PostgreSQL?

The default is 4 gigabytes ( 4GB ).

What is default page size in Postgres?

PostgreSQL maintains data in fixed-sized storage units called pages. The size of a page is defined during the PostgreSQL server compilation process. The default page size is 8k, but this can be changed to a higher value.


2 Answers

When you execute

SHOW shared_buffers;

I get something like

 shared_buffers
----------------
 256MB
(1 row)

This tells the the current value.

like image 166
DrColossos Avatar answered Sep 19 '22 15:09

DrColossos


shared_buffers is counted in disk blocks. The default block_size setting is 8kB, and can't be changed without recompiling the server, so that's almost certainly what you're using. This would mean that shared_buffers=16384 equates to 128MB.

SELECT * FROM pg_settings will show you the base units for a setting, among other things. As @DrColossos pointed out, SHOW shared_buffers will give you a qualified amount, and like @Raptor said, you can (and should!) specify units for any setting which has them.

like image 45
Nick Barnes Avatar answered Sep 19 '22 15:09

Nick Barnes