Fixing high buffer usage

The question is now: how can the situation be improved? One way to do that is to run a CLUSTER clause:

test=# \h CLUSTERCommand:     CLUSTERDescription: cluster a table according to an indexSyntax:CLUSTER [VERBOSE] table_name[ USING index_name ] CLUSTER [VERBOSE]

The CLUSTER clause will rewrite the table in the same order as a (b-tree) index. If you are running an analytical workload, this can make sense. However, in an OLTP system, the CLUSTER clause might not be feasible because a table lock is required while the table is rewritten.

Get Mastering PostgreSQL 10 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.