Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shared buffer in postgres

Tags:

postgresql

I am curious about the role played by shared buffer in postgres. Shared buffer maintains all the recently accessed disk pages and dirty pages. If a new page needs to be brought in and there is no space left in shared buffer, a victim dirty page is written back to the disk.

However, I am confused about this statement- PostgreSQL depends on the OS for caching. (http://www.varlena.com/GeneralBits/Tidbits/perf.html#shbuf)"

How does postgres depends on the OS for caching? And how does it change the behavior of shared buffer?

like image 920
pree Avatar asked May 30 '11 11:05

pree


People also ask

What is shared buffers in Postgres?

Sets the amount of memory the database server uses for shared memory buffers. The default is typically 128 megabytes ( 128MB ), 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 are shared memory buffers?

A primary benefit of shared memory is the ability of database server threads to share access to disk pages stored in the shared-memory buffer pool. The database server maintains thread isolation while it achieves this increased concurrency through a strategy for locking the data buffers.

What is effective cache size in PostgreSQL?

The default is 4 gigabytes ( 4GB ).


1 Answers

Postgresql uses the OS cache and its own data cache. The two are useful according to your database usage.

OS cache is very fast but basic: it removes older data with the new one. It is useful for very versatile query results. PG cache is slower (still much faster than disk) but it keeps usage counters of the most used data. Useful for recurrent results/index.

like image 183
Guillaume Savary Avatar answered Sep 17 '22 15:09

Guillaume Savary