VALIDATE CHUNKS INDEXES
VALIDATE_CHUNKS_INDEXES cross-checks the chunk index of a single column against the table’s real chunks, and reports what does not line up.
Use it when a filtered statement returns unexpected results or scans more chunks than expected, to establish whether the column’s index is complete and still matches the data. On a healthy index, chunks_not_indexed, minmax_mismatches, and positions_misaligned are all 0.
See also Accelerating Filtered Statements, GET CHUNK INFO.
Permissions
The role must have the SUPERUSER permissions.
Syntax
validate_chunks_indexes_statement ::=
SELECT VALIDATE_CHUNKS_INDEXES('<schema_name>.<table_name>', '<column_name>' [, '<case_sensitive_names>'])
;
Parameters
Parameter |
Description |
|---|---|
|
The schema and table, given as a single dotted argument |
|
The name of the column whose index is checked |
|
Optional. |
Returns
One row per internal column, so a single column usually returns more than one row. A nullable column adds a @null internal column, and a TEXT column is stored as @vclen and @vcblob. A nullable TEXT column therefore returns three rows.
Column name |
Description |
|---|---|
|
The internal column id |
|
The internal column name |
|
Number of index pages written for this column |
|
Number of chunks that appear in the index |
|
Number of chunks the table actually has |
|
Chunks in the table with no entry in the index |
|
Index entries pointing at chunks that no longer exist |
|
Index entries pointing at chunks marked as deleted |
|
Chunks appearing in the index more than once |
|
Entries whose minimum and maximum values disagree with the chunk itself |
|
The lowest chunk id in the index, or |
|
The highest chunk id in the index, or |
|
Entry positions that do not line up across the columns of the index |
Notes
VALIDATE_CHUNKS_INDEXESchecks one column per call rather than reporting on a whole table.The statement reads the index directly for the column given, rather than scanning the whole table index.
Examples
Checking a column that has no index
Checking a nullable TEXT column returns three rows, one per internal column. Here the column has no index, so every chunk is reported as not indexed:
t=> SELECT VALIDATE_CHUNKS_INDEXES('public.readtable_synth', 'message');
column_id | column_name | index_pages | indexed_chunks | table_chunks_total | chunks_not_indexed | chunks_indexed_but_missing | chunks_indexed_but_deleted | duplicate_chunk_entries | minmax_mismatches | first_indexed_chunk_id | last_indexed_chunk_id | positions_misaligned
----------+--------------------+-------------+----------------+--------------------+--------------------+----------------------------+----------------------------+-------------------------+-------------------+------------------------+-----------------------+---------------------
2 | message@null | 0 | 0 | 3 | 3 | 0 | 0 | 0 | 0 | -1 | -1 | 0
3 | message@val@vclen | 0 | 0 | 3 | 3 | 0 | 0 | 0 | 0 | -1 | -1 | 0
4 | message@val@vcblob | 0 | 0 | 3 | 3 | 0 | 0 | 0 | 0 | -1 | -1 | 0
Rebuilding an index and checking the result
SELECT RECALCULATE_CHUNKS_INDEXES('public.readtable_synth', 'message');
SELECT VALIDATE_CHUNKS_INDEXES('public.readtable_synth', 'message');
On a healthy index, chunks_not_indexed, minmax_mismatches, and positions_misaligned are 0, and indexed_chunks equals table_chunks_total.