Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support CAGG names in chunk_detailed_size #5839

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .unreleased/PR_5839
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Implements: #5839 Support CAGG names in chunk_detailed_size
14 changes: 12 additions & 2 deletions sql/size_utils.sql
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,18 @@ BEGIN
INNER JOIN _timescaledb_catalog.hypertable ht ON (ht.schema_name = n.nspname AND ht.table_name = c.relname)
WHERE c.OID = hypertable;

IF table_name IS NULL THEN
RETURN;
IF table_name IS NULL THEN
SELECT h.schema_name, h.table_name, replication_factor > 0
INTO schema_name, table_name, is_distributed
FROM pg_class c
INNER JOIN pg_namespace n ON (n.OID = c.relnamespace)
INNER JOIN _timescaledb_catalog.continuous_agg a ON (a.user_view_schema = n.nspname AND a.user_view_name = c.relname)
INNER JOIN _timescaledb_catalog.hypertable h ON h.id = a.mat_hypertable_id
WHERE c.OID = hypertable;

IF table_name IS NULL THEN
RETURN;
END IF;
END IF;

CASE WHEN is_distributed THEN
Expand Down
22 changes: 22 additions & 0 deletions tsl/test/expected/size_utils_tsl.out
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ SELECT * FROM hypertable_detailed_size(:'MAT_HYPERTABLE_NAME') ORDER BY node_nam
0 | 8192 | 8192 | 16384 |
(1 row)

SELECT * FROM chunks_detailed_size(:'MAT_HYPERTABLE_NAME') ORDER BY node_name;
chunk_schema | chunk_name | table_bytes | index_bytes | toast_bytes | total_bytes | node_name
--------------+------------+-------------+-------------+-------------+-------------+-----------
(0 rows)

SELECT * FROM hypertable_size('hypersize_cagg');
hypertable_size
-----------------
Expand All @@ -42,6 +47,11 @@ SELECT * FROM hypertable_detailed_size('hypersize_cagg') ORDER BY node_name;
0 | 8192 | 8192 | 16384 |
(1 row)

SELECT * FROM chunks_detailed_size('hypersize_cagg') ORDER BY node_name;
chunk_schema | chunk_name | table_bytes | index_bytes | toast_bytes | total_bytes | node_name
--------------+------------+-------------+-------------+-------------+-------------+-----------
(0 rows)

-- Test size functions on non-empty countinuous aggregate
CALL refresh_continuous_aggregate('hypersize_cagg', NULL, NULL);
SELECT * FROM hypertable_size('hypersize_cagg');
Expand All @@ -56,6 +66,12 @@ SELECT * FROM hypertable_detailed_size('hypersize_cagg') ORDER BY node_name;
8192 | 24576 | 16384 | 49152 |
(1 row)

SELECT * FROM chunks_detailed_size('hypersize_cagg') ORDER BY node_name;
chunk_schema | chunk_name | table_bytes | index_bytes | toast_bytes | total_bytes | node_name
-----------------------+------------------+-------------+-------------+-------------+-------------+-----------
_timescaledb_internal | _hyper_2_2_chunk | 8192 | 16384 | 8192 | 32768 |
(1 row)

SELECT * FROM hypertable_size(:'MAT_HYPERTABLE_NAME');
hypertable_size
-----------------
Expand All @@ -68,3 +84,9 @@ SELECT * FROM hypertable_detailed_size(:'MAT_HYPERTABLE_NAME') ORDER BY node_nam
8192 | 24576 | 16384 | 49152 |
(1 row)

SELECT * FROM chunks_detailed_size(:'MAT_HYPERTABLE_NAME') ORDER BY node_name;
chunk_schema | chunk_name | table_bytes | index_bytes | toast_bytes | total_bytes | node_name
-----------------------+------------------+-------------+-------------+-------------+-------------+-----------
_timescaledb_internal | _hyper_2_2_chunk | 8192 | 16384 | 8192 | 32768 |
(1 row)

5 changes: 4 additions & 1 deletion tsl/test/sql/size_utils_tsl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ WHERE user_view_name = 'hypersize_cagg'

SELECT * FROM hypertable_size(:'MAT_HYPERTABLE_NAME');
SELECT * FROM hypertable_detailed_size(:'MAT_HYPERTABLE_NAME') ORDER BY node_name;
SELECT * FROM chunks_detailed_size(:'MAT_HYPERTABLE_NAME') ORDER BY node_name;
SELECT * FROM hypertable_size('hypersize_cagg');
SELECT * FROM hypertable_detailed_size('hypersize_cagg') ORDER BY node_name;
SELECT * FROM chunks_detailed_size('hypersize_cagg') ORDER BY node_name;

-- Test size functions on non-empty countinuous aggregate
CALL refresh_continuous_aggregate('hypersize_cagg', NULL, NULL);
SELECT * FROM hypertable_size('hypersize_cagg');
SELECT * FROM hypertable_detailed_size('hypersize_cagg') ORDER BY node_name;
SELECT * FROM chunks_detailed_size('hypersize_cagg') ORDER BY node_name;
SELECT * FROM hypertable_size(:'MAT_HYPERTABLE_NAME');
SELECT * FROM hypertable_detailed_size(:'MAT_HYPERTABLE_NAME') ORDER BY node_name;

SELECT * FROM chunks_detailed_size(:'MAT_HYPERTABLE_NAME') ORDER BY node_name;