The job of a buffer manager is to manage and oversee the data transfers that take place persistent memory and shared memory and thus, this part of the DBMS can have a significant impact on the performance and working of the RDBMS. In PostgreSQL however, the buffer manager works very well and efficiently.
In this brief overview, we will take a look at the following sections and get an understanding of the topics:
- Buffer manager structure
The buffer manager in postgreSQL consists of a buffer descriptor, a buffer table and a buffer pool. Things like the data file pages e.g. the tables and indexes and the freespace maps and visibility maps as well. Next, the buffer pool is in the form of an array which basically entails that each of the slots store a single page of the data file. The indices of a buffer pool array are known as buffer_ids
- Buffer manager locks
The buffer manager locks are used for many different purposes and uses many different locks. Now, we will look at the locks that are necessary for understanding the upcoming sections.
Firstly, there are Buffer Table Locks which help protect the integrity of the data that is contained in the entire buffer table. This can be used in both the exclusive and shared modes and is considered a relatively light weight lock. Whenever an entry is inserted or deleted, an exclusive lock is held by a backend process.
- How the buffer manager works
A buffer manager works whenever a backend process wants to access a desired page. When this task is to be performed, is uses a ReadBufferExtended function.
How the ReadBufferExtended function behaves depends on three different logical cases. Additionally, we will look at the PostgreSQL clock sweep page replacement algorithm in the final section.
- Ring buffer
Whenever PostgreSQL is reading or writing a very large table, a ring buffer is used instead of a buffer pool. A small and temporary buffer area is assigned as a ring buffer in the main memory. Bulk reading, bulk writing and Vacuum-processing are the three main operations where ring buffer is used.
*- Flushing of dirty pages *
The background writer and check pointer does processing of flushing dirty pages to storage. Both of these processes perform the same function however, each have different behaviors and roles.
The role of the background writer is to decrease the influence of large scale writing of checkpointing. Whereas the checkpoint process writes a checkpoint record to the WAL segment and whenever the checkpointing starts it flushes the dirty pages.
Top comments (0)