3

How to detect corrupted indexes in PostgreSQL?

When I pull data from a column with primary key attribute in a table with where condition, it brings incomplete results. Likewise, when I sort with order by in the relevant column, the data is missing. When you dump the table and press it to another database or transfer the table to another table by changing its name, the data comes back healthy. In this case I suspect the primary key is corrupt. What do I need to do to scan the whole database for corrupt primary keys.

2
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.
    – Community
    Commented Aug 23, 2022 at 13:41
  • I edited it, can you review it again?
    – emreyanik
    Commented Aug 24, 2022 at 7:08

1 Answer 1

4

Run the bt_index_parent_check function from the amcheck extension. That can detect most cases of data corruption in a given index.

1
  • thank you, i will try
    – emreyanik
    Commented Aug 24, 2022 at 7:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.