mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-22 13:40:56 +08:00
Add compression settings view
Add informational view that lists the settings used while enabling compression on a hypertable.
This commit is contained in:
parent
88f693887a
commit
926a1c9850
@ -259,5 +259,28 @@ CREATE OR REPLACE VIEW timescaledb_information.data_node AS
|
|||||||
LEFT OUTER JOIN LATERAL @extschema@.data_node_hypertable_info(CASE WHEN s.node_up THEN s.node_name ELSE NULL END) size ON TRUE
|
LEFT OUTER JOIN LATERAL @extschema@.data_node_hypertable_info(CASE WHEN s.node_up THEN s.node_name ELSE NULL END) size ON TRUE
|
||||||
GROUP BY s.node_name, s.node_up, s.owner, s.options;
|
GROUP BY s.node_name, s.node_up, s.owner, s.options;
|
||||||
|
|
||||||
|
---compression parameters information ---
|
||||||
|
CREATE VIEW timescaledb_information.compression_settings
|
||||||
|
AS
|
||||||
|
SELECT
|
||||||
|
ht.schema_name,
|
||||||
|
ht.table_name,
|
||||||
|
segq.attname,
|
||||||
|
segq.segmentby_column_index,
|
||||||
|
segq.orderby_column_index,
|
||||||
|
segq.orderby_asc,
|
||||||
|
segq.orderby_nullsfirst
|
||||||
|
FROM
|
||||||
|
_timescaledb_catalog.hypertable_compression segq,
|
||||||
|
_timescaledb_catalog.hypertable ht
|
||||||
|
WHERE
|
||||||
|
segq.hypertable_id = ht.id
|
||||||
|
AND ( segq.segmentby_column_index IS NOT NULL
|
||||||
|
OR segq.orderby_column_index IS NOT NULL)
|
||||||
|
ORDER BY
|
||||||
|
table_name,
|
||||||
|
segmentby_column_index,
|
||||||
|
orderby_column_index;
|
||||||
|
|
||||||
GRANT USAGE ON SCHEMA timescaledb_information TO PUBLIC;
|
GRANT USAGE ON SCHEMA timescaledb_information TO PUBLIC;
|
||||||
GRANT SELECT ON ALL TABLES IN SCHEMA timescaledb_information TO PUBLIC;
|
GRANT SELECT ON ALL TABLES IN SCHEMA timescaledb_information TO PUBLIC;
|
||||||
|
@ -535,6 +535,7 @@ WHERE refclassid = 'pg_catalog.pg_extension'::pg_catalog.regclass AND
|
|||||||
ORDER BY objid::text DESC;
|
ORDER BY objid::text DESC;
|
||||||
objid
|
objid
|
||||||
-----------------------------------------------------
|
-----------------------------------------------------
|
||||||
|
timescaledb_information.compression_settings
|
||||||
timescaledb_information.data_node
|
timescaledb_information.data_node
|
||||||
timescaledb_information.compressed_hypertable_stats
|
timescaledb_information.compressed_hypertable_stats
|
||||||
timescaledb_information.compressed_chunk_stats
|
timescaledb_information.compressed_chunk_stats
|
||||||
@ -550,7 +551,7 @@ WHERE refclassid = 'pg_catalog.pg_extension'::pg_catalog.regclass AND
|
|||||||
_timescaledb_internal.bgw_policy_chunk_stats
|
_timescaledb_internal.bgw_policy_chunk_stats
|
||||||
_timescaledb_internal.bgw_job_stat
|
_timescaledb_internal.bgw_job_stat
|
||||||
_timescaledb_catalog.tablespace_id_seq
|
_timescaledb_catalog.tablespace_id_seq
|
||||||
(15 rows)
|
(16 rows)
|
||||||
|
|
||||||
-- Make sure we can't run our restoring functions as a normal perm user as that would disable functionality for the whole db
|
-- Make sure we can't run our restoring functions as a normal perm user as that would disable functionality for the whole db
|
||||||
\c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER
|
\c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER
|
||||||
|
@ -63,6 +63,15 @@ select * from _timescaledb_catalog.hypertable_compression order by hypertable_id
|
|||||||
1 | d | 4 | | 2 | t | f
|
1 | d | 4 | | 2 | t | f
|
||||||
(4 rows)
|
(4 rows)
|
||||||
|
|
||||||
|
select * from timescaledb_information.compression_settings ;
|
||||||
|
schema_name | table_name | attname | segmentby_column_index | orderby_column_index | orderby_asc | orderby_nullsfirst
|
||||||
|
-------------+------------+---------+------------------------+----------------------+-------------+--------------------
|
||||||
|
public | foo | a | 1 | | |
|
||||||
|
public | foo | b | 2 | | |
|
||||||
|
public | foo | c | | 1 | f | t
|
||||||
|
public | foo | d | | 2 | t | f
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
-- TEST2 compress-chunk for the chunks created earlier --
|
-- TEST2 compress-chunk for the chunks created earlier --
|
||||||
select compress_chunk( '_timescaledb_internal._hyper_1_2_chunk');
|
select compress_chunk( '_timescaledb_internal._hyper_1_2_chunk');
|
||||||
compress_chunk
|
compress_chunk
|
||||||
@ -1124,6 +1133,32 @@ ERROR: constraint "fk_table1" requires column "col2" to be a timescaledb.compre
|
|||||||
ALTER TABLE table1 SET (timescaledb.compress, timescaledb.compress_segmentby = 'col1,col2');
|
ALTER TABLE table1 SET (timescaledb.compress, timescaledb.compress_segmentby = 'col1,col2');
|
||||||
NOTICE: adding index _compressed_hypertable_23_col1__ts_meta_sequence_num_idx ON _timescaledb_internal._compressed_hypertable_23 USING BTREE(col1, _ts_meta_sequence_num)
|
NOTICE: adding index _compressed_hypertable_23_col1__ts_meta_sequence_num_idx ON _timescaledb_internal._compressed_hypertable_23 USING BTREE(col1, _ts_meta_sequence_num)
|
||||||
NOTICE: adding index _compressed_hypertable_23_col2__ts_meta_sequence_num_idx ON _timescaledb_internal._compressed_hypertable_23 USING BTREE(col2, _ts_meta_sequence_num)
|
NOTICE: adding index _compressed_hypertable_23_col2__ts_meta_sequence_num_idx ON _timescaledb_internal._compressed_hypertable_23 USING BTREE(col2, _ts_meta_sequence_num)
|
||||||
|
SELECT * FROM timescaledb_information.compression_settings ORDER BY table_name;
|
||||||
|
schema_name | table_name | attname | segmentby_column_index | orderby_column_index | orderby_asc | orderby_nullsfirst
|
||||||
|
-------------+----------------+-------------+------------------------+----------------------+-------------+--------------------
|
||||||
|
public | conditions | location | 1 | | |
|
||||||
|
public | conditions | time | | 1 | t | f
|
||||||
|
public | datatype_test | time | | 1 | f | t
|
||||||
|
public | foo | a | 1 | | |
|
||||||
|
public | foo | b | 2 | | |
|
||||||
|
public | foo | c | | 1 | f | t
|
||||||
|
public | foo | d | | 2 | t | f
|
||||||
|
public | ht5 | time | | 1 | f | t
|
||||||
|
public | hyper | device_id | 1 | | |
|
||||||
|
public | hyper | time | | 1 | t | f
|
||||||
|
public | metrics | time | | 1 | f | t
|
||||||
|
public | plan_inval | time | | 1 | f | t
|
||||||
|
public | rescan_test | id | 1 | | |
|
||||||
|
public | rescan_test | t | | 1 | f | t
|
||||||
|
public | table1 | col1 | 1 | | |
|
||||||
|
public | table1 | col2 | 2 | | |
|
||||||
|
public | test_collation | device_id | 1 | | |
|
||||||
|
public | test_collation | device_id_2 | 2 | | |
|
||||||
|
public | test_collation | val_1 | | 1 | t | f
|
||||||
|
public | test_collation | val_2 | | 2 | t | f
|
||||||
|
public | test_collation | time | | 3 | t | f
|
||||||
|
(21 rows)
|
||||||
|
|
||||||
-- test delete/update on non-compressed tables involving hypertables with compression
|
-- test delete/update on non-compressed tables involving hypertables with compression
|
||||||
CREATE TABLE uncompressed_ht (
|
CREATE TABLE uncompressed_ht (
|
||||||
time timestamptz NOT NULL,
|
time timestamptz NOT NULL,
|
||||||
|
@ -29,6 +29,7 @@ SET timescaledb.enable_transparent_decompression to OFF;
|
|||||||
select id, schema_name, table_name, compressed, compressed_hypertable_id from
|
select id, schema_name, table_name, compressed, compressed_hypertable_id from
|
||||||
_timescaledb_catalog.hypertable order by id;
|
_timescaledb_catalog.hypertable order by id;
|
||||||
select * from _timescaledb_catalog.hypertable_compression order by hypertable_id, attname;
|
select * from _timescaledb_catalog.hypertable_compression order by hypertable_id, attname;
|
||||||
|
select * from timescaledb_information.compression_settings ;
|
||||||
|
|
||||||
-- TEST2 compress-chunk for the chunks created earlier --
|
-- TEST2 compress-chunk for the chunks created earlier --
|
||||||
select compress_chunk( '_timescaledb_internal._hyper_1_2_chunk');
|
select compress_chunk( '_timescaledb_internal._hyper_1_2_chunk');
|
||||||
@ -451,6 +452,7 @@ SELECT create_hypertable('table1','col1', chunk_time_interval => 10);
|
|||||||
ALTER TABLE table1 SET (timescaledb.compress, timescaledb.compress_segmentby = 'col1');
|
ALTER TABLE table1 SET (timescaledb.compress, timescaledb.compress_segmentby = 'col1');
|
||||||
-- Listing all fields of the compound key should succeed:
|
-- Listing all fields of the compound key should succeed:
|
||||||
ALTER TABLE table1 SET (timescaledb.compress, timescaledb.compress_segmentby = 'col1,col2');
|
ALTER TABLE table1 SET (timescaledb.compress, timescaledb.compress_segmentby = 'col1,col2');
|
||||||
|
SELECT * FROM timescaledb_information.compression_settings ORDER BY table_name;
|
||||||
|
|
||||||
-- test delete/update on non-compressed tables involving hypertables with compression
|
-- test delete/update on non-compressed tables involving hypertables with compression
|
||||||
CREATE TABLE uncompressed_ht (
|
CREATE TABLE uncompressed_ht (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user