NAME

DBIO::ClickHouse::Introspect::Indexes - Introspect ClickHouse data-skipping indexes via system.data_skipping_indices

VERSION

version 0.900004

DESCRIPTION

Fetches ClickHouse data-skipping index metadata from system.data_skipping_indices, scoped to one database and filtered to the tables surfaced by DBIO::ClickHouse::Introspect::Tables.

These are not indexes in the DBIO sense

A data-skipping index is not a B-tree and not a constraint. It is a per-granule summary (minmax, set(N), bloom_filter, ngrambf_v1, ...) over an expression, used to skip granules during a scan. It enforces nothing, it does not accelerate point lookups, and there is no unique variant.

Consequently this reader deliberately does not produce the canonical indexes section shape (is_unique + columns), and "table_uniq_info" in DBIO::ClickHouse::Introspect does not read it. Feeding a skipping index into table_uniq_info would generate an add_unique_constraint in a regenerated schema and DBIO would then trust a uniqueness ClickHouse never promised -- silently wrong lookups, not a missing optimization. They get their own model section, data_skipping_indexes.

They are also declared inline in CREATE TABLE (INDEX name expr TYPE minmax GRANULARITY 4), not with CREATE INDEX, so the diff layer has to treat adding one as ALTER TABLE ... ADD INDEX and must know the granularity to render it.

METHODS

fetch

my $indexes = DBIO::ClickHouse::Introspect::Indexes->fetch($dbh, $tables);
my $indexes = DBIO::ClickHouse::Introspect::Indexes->fetch($dbh, $tables, $database);

Returns a hashref keyed by table name, each value a hashref keyed by index name with: index_name, expr (the indexed expression, verbatim), type (the bare index type, e.g. minmax), type_full (with arguments, e.g. set(100)) and granularity.

Returns an empty hashref when the query fails -- system.data_skipping_indices is missing on pre-20.x servers and can be hidden by READ grants, and neither is a reason to make the whole introspection unusable.

SEE ALSO

AUTHOR

DBIO Authors

COPYRIGHT AND LICENSE

Copyright (C) 2026 DBIO Authors

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.