O'Reilly logo

PostgreSQL High Performance Cookbook by Dinesh Kumar, Chitij Chauhan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Vacuum and autovacuum

In this recipe, we will be discussing the importance of vacuum and autovacuum in achieving good PostgreSQL performance.

Getting ready

As aforementioned, PostgreSQL is based on MVCC. As a net result, we will have all the non-visible tuples beside visible tuples, which occupy the underlying disk storage. As of now, these non-visible tuples have no use, and if we could reclaim or reuse the non-visible tuple's disk storage, that would make the disk utilization more effective.

How to do it...

Let's experiment with the usage of VACUUM by creating a sample table and executing a few SQL statements that generate non-visible tuples or dead tuples.

Connect to your database using psql as a super user and then execute the following command: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required