timescaledb_information.chunks

Get metadata about the chunks of hypertables.

This view shows metadata for the chunk’s primary time-based dimension. For information about a hypertable’s secondary dimensions, the dimensions view should be used instead.

If the chunk’s primary dimension is of a time datatype, range_start and range_end are set. Otherwise, if the primary dimension type is integer based, range_start_integer and range_end_integer are set.

Available Columns

NameDescription
hypertable_schema(NAME) Schema name of the hypertable
hypertable_name(NAME) Table name of the hypertable
chunk_schema(NAME) Schema name of the chunk
chunk_name(NAME) Name of the chunk
primary_dimension(NAME) Name of the column that is the primary dimension
primary_dimension_type(REGTYPE) Type of the column that is the primary dimension
range_start(TIMESTAMP WITH TIME ZONE) Start of the range for the chunk’s dimension
range_end(TIMESTAMP WITH TIME ZONE) End of the range for the chunk’s dimension
range_start_integer(BIGINT) Start of the range for the chunk’s dimension, if the dimension type is integer based
range_end_integer(BIGINT) End of the range for the chunk’s dimension, if the dimension type is integer based
is_compressed(BOOLEAN) Is the data in the chunk compressed? NULL for distributed chunks. Use chunk_compression_stats() function to get compression status for distributed chunks.
chunk_tablespace(NAME) Tablespace used by the chunk
data_nodes(NAME[]) Nodes on which the chunk is replicated. This is applicable only to chunks for distributed hypertables

Sample Usage

Get information about the chunks of a hypertable.

  1. CREATE TABLESPACE tablespace1 location '/usr/local/pgsql/data1';
  2. CREATE TABLE hyper_int (a_col integer, b_col integer, c integer);
  3. SELECT table_name from create_hypertable('hyper_int', 'a_col', chunk_time_interval=> 10);
  4. CREATE OR REPLACE FUNCTION integer_now_hyper_int() returns int LANGUAGE SQL STABLE as $$ SELECT coalesce(max(a_col), 0) FROM hyper_int $$;
  5. SELECT set_integer_now_func('hyper_int', 'integer_now_hyper_int');
  6. INSERT INTO hyper_int SELECT generate_series(1,5,1), 10, 50;
  7. SELECT attach_tablespace('tablespace1', 'hyper_int');
  8. INSERT INTO hyper_int VALUES( 25 , 14 , 20), ( 25, 15, 20), (25, 16, 20);
  9. SELECT * FROM timescaledb_information.chunks WHERE hypertable_name = 'hyper_int';
  10. -[ RECORD 1 ]----------+----------------------
  11. hypertable_schema | public
  12. hypertable_name | hyper_int
  13. chunk_schema | _timescaledb_internal
  14. chunk_name | _hyper_7_10_chunk
  15. primary_dimension | a_col
  16. primary_dimension_type | integer
  17. range_start |
  18. range_end |
  19. range_start_integer | 0
  20. range_end_integer | 10
  21. is_compressed | f
  22. chunk_tablespace |
  23. data_nodes |
  24. -[ RECORD 2 ]----------+----------------------
  25. hypertable_schema | public
  26. hypertable_name | hyper_int
  27. chunk_schema | _timescaledb_internal
  28. chunk_name | _hyper_7_11_chunk
  29. primary_dimension | a_col
  30. primary_dimension_type | integer
  31. range_start |
  32. range_end |
  33. range_start_integer | 20
  34. range_end_integer | 30
  35. is_compressed | f
  36. chunk_tablespace | tablespace1
  37. data_nodes |