timescaledb/sql/dist_internal.sql
Brian Rowe e110a42a2b Add space usage utilities to distributed database
This change adds a new utility function for postgres
`server_hypertable_info`.  This function will contact a provided node
and pull down the space information for all the distributed hypertables
on that node.

Additionally, a new view `distributed_server_info` has been added to
timescaledb_information.  This view leverages the new
remote_hypertable_data function to display a list of nodes, along with
counts of tables, chunks, and total bytes used by distributed data.

Finally, this change also adds a `hypertable_server_relation_size`
function, which, given the name of a distributed hypertable, will print
the space information for that hypertable on each node of the
distributed database.
2020-05-27 17:31:09 +02:00

28 lines
1.1 KiB
SQL

-- This file and its contents are licensed under the Apache License 2.0.
-- Please see the included NOTICE for copyright information and
-- LICENSE-APACHE for a copy of the license.
CREATE OR REPLACE FUNCTION _timescaledb_internal.set_dist_id(dist_id UUID) RETURNS BOOL
AS '@MODULE_PATHNAME@', 'ts_dist_set_id' LANGUAGE C VOLATILE STRICT;
CREATE OR REPLACE FUNCTION _timescaledb_internal.remove_from_dist_db() RETURNS BOOL
AS '@MODULE_PATHNAME@', 'ts_dist_remove_id' LANGUAGE C VOLATILE STRICT;
CREATE OR REPLACE FUNCTION _timescaledb_internal.set_peer_dist_id(dist_id UUID) RETURNS BOOL
AS '@MODULE_PATHNAME@', 'ts_dist_set_peer_id' LANGUAGE C VOLATILE STRICT;
CREATE OR REPLACE FUNCTION server_hypertable_info(
server_name NAME
)
RETURNS TABLE (id int,
table_schema name,
table_name name,
table_owner name,
num_dimensions smallint,
num_chunks bigint,
distributed bool,
table_bytes bigint,
index_bytes bigint,
toast_bytes bigint,
total_bytes bigint)
AS '@MODULE_PATHNAME@', 'ts_dist_remote_hypertable_info' LANGUAGE C VOLATILE STRICT;