Skip to main content
Checks one or more tables for corrupted data, by reading every column of every chunk of each table from disk, on every rank. Chunks whose data cannot be read are reported and marked as corrupt. Checking a table requires read permission on it; tables the user cannot read are skipped without error, as are views.
CHECK TABLE Syntax
CHECK TABLE only reads data, but any chunks it finds to be corrupt are marked as such, and, by default, the database then repairs them automatically in the background: each corrupted chunk is truncated to a consistent length or, if that fails, deleted, and the records lost are not recoverable. To review any corruption before data is removed, set wal.auto_truncate_corrupt_tables to false in the system configuration and repair the table with REPAIR TABLE. Until a table marked as corrupt is repaired, reads from and deletes on it fail.
Because CHECK TABLE loads every column of each table into memory, checking large tables can take a long time and can displace data that other queries are using. Queries can read a table while it is being checked, but some changes to the table wait until its check is complete. Consider checking large tables, or all tables with *, during a period of low activity.

Parameters

<schema name>

Name of the schema containing the table to check

<table name>

Name of the table to check; multiple tables can be given as a comma-separated list

*

Check all tables

WITH OPTIONS

Optional indicator that a comma-delimited list of option/value assignments will follow; see the options below

Options

LOCAL_ONLY

If true, only check column data that has a copy in the local persist tier; data held only in cold storage is skipped, and so is not checked. The default is false, which downloads data held only in cold storage in order to check it.

SHOW_DETAIL

If true (the default), report each corrupted chunk individually. If false, report only a count of the corrupted chunks found for each table at each location.

Response

CHECK TABLE returns rows only for tables with corrupted data; a table with no corruption produces no rows. By default, each row describes one corrupted chunk; with SHOW_DETAIL set to false, each row summarizes the corrupted chunks of one table at one location.

Examples

To check two tables for corrupted data:
CHECK TABLE Example
To check a table, reporting only a count of corrupted chunks for each location and skipping data held only in cold storage:
CHECK TABLE with Options Example