Book Image

PostgreSQL Administration Essentials

Book Image

PostgreSQL Administration Essentials

Overview of this book

Table of Contents (14 chapters)

Configuring the checkpoints


Now that you have seen what xlog is good for, it is necessary to discuss the concept of checkpoints. Let's assume we are inserting data just like we did earlier:

INSERT INTO foo VALUES ('abcdefg');

As you might expect, the ultimate goal of this INSERT statement is to write the new data to a table. In PostgreSQL, a table is always represented by a couple of datafiles consisting of 8k blocks (unless changed at compile time). The core question now is: is it desirable to write to the table directly? As discussed earlier in this chapter, writing to the table directly is not feasible anyway because in case of a crash, things would go south. Therefore, we go to the transaction log first. But this is not the end of the story as the next diagram shows:

Once the data has been sent to the transaction log, a copy of the future block on disk will be placed inside PostgreSQL shared buffers—data does not necessarily have to go to the table instantly; it is perfectly fine if the...