Thursday , June 13 2024

Postgresql Unlogged Table

In today’s article, we will cover about the Postgresql Unlogged Table feature, which came into our lives with the PostgreSQL 9.1 version and significantly increased our typing speed.

PostgreSQL protects our data in most cases, and even if it shuts down in an emergency, our data is securely protected. It monitors every change in the table using PostgreSQL WAL. This causes I\O on the disk side, but doing this ensures that our data is kept securely.

Unlogged Tables are generally efficient in terms of writing speed, but since they are not written to WAL like normal tables, we are likely to lose data.

Unlogged Tables can be useful for data that can be easily recreated in bulk transactions, but your data may be lost in a sudden shutdown.

For example:

You can use the command below to change the current table to unlogged.
Let’s take an example to see the difference between unlogged and regular tables.

First, let’s create our table.

After creating our table, let’s insert 10 000 000 random data.

10 000 000 random data inserts took 33 seconds and 894 ms as seen below.

Let’s insert the table that is not unlogged. Let’s create our flat table without being unlogged.

After creating our table, let’s insert the same data.

As seen above, our tabled2 table takes longer.


About Faruk Erdem

Leave a Reply

Your email address will not be published. Required fields are marked *