amcheck
functions for verifying relation integrity
amcheck : functions for verifying relation integrity
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 5980 | amcheck | amcheck | 1.4 |
ADMIN | PostgreSQL | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --s-d-- | No | Yes | No | Yes | no | no |
| Relationships | |
|---|---|
| See Also | pg_checksums pg_catcheck pg_orphaned pg_pathcheck pg_isok pg_surgery pageinspect adminpack pg_repack |
Packages
| PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|
| 1.4 | 1.4 | 1.4 | 1.4 | 1.4 |
This is a built-in contrib extension ship with the PostgreSQL kernel
Install
Create this extension with:
Usage
The amcheck extension provides functions to verify the logical consistency of B-tree indexes, GIN indexes, and heap (table) data, detecting corruption without modifying data.
B-Tree Index Verification
Check All Catalog Indexes
GIN Index Verification
Heap (Table) Verification
Returns rows for each detected problem:
| Column | Type | Description |
|---|---|---|
blkno |
bigint | Block number with corruption |
offnum |
integer | Offset of corrupt tuple |
attnum |
integer | Attribute number (if column-specific) |
msg |
text | Description of the problem |
Function Summary
| Function | Lock | Use Case |
|---|---|---|
bt_index_check(index, heapallindexed, checkunique) |
AccessShareLock | Routine production checks |
bt_index_parent_check(index, heapallindexed, rootdescend, checkunique) |
ShareLock | Comprehensive verification |
gin_index_check(index) |
AccessShareLock | GIN index verification |
verify_heapam(relation, on_error_stop, check_toast, skip, startblock, endblock) |
AccessShareLock | Table/heap corruption detection |
All amcheck errors are true positives. Use REINDEX or point-in-time recovery for repair after diagnosing with pageinspect.