Inspecting storage using pageinspect

If you are facing storage corruption or some other storage-related problem that might be related to bad blocks in a table, the pageinspect extension might be the module you are looking for:

test=# CREATE EXTENSION pageinspect;CREATE EXTENSION

The idea behind pageinspect is to provide you with a module that allows you to inspect a table on the binary level.

When using the module, the most important thing to do is to fetch a block:

test=# SELECT * FROM get_raw_page('pg_class', 0);...

The function will return a single block. In the preceding example, it is the first block in the pg_class parameter, which is a system table (of course, you can use any other table you want).

In the next step, you can extract ...

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.