-
Notifications
You must be signed in to change notification settings - Fork 883
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add aliases for compression functions and views
This adds a set of aliases for existing compression functions and view to better reflect the column store capabilities of compressed hypertables. The procedures `convert_to_rowstore` and `convert_to_columnstore` are added as aliases to `decompress_chunk` and `compress_chunk` respectively. We change these from functions to procedures to be able to split the conversion into multiple transactions and avoid heavy locking for longer periods. The procedures `add_columnstore_policy` and `remove_columnstore_policy` are added as alias for `add_compression_policy` and `remove_compression_policy` respectively. The functions `hypertable_columnstore_stats` and `chunk_columnstore_stats` are added as aliases for `hypertable_compression_stats` and `chunk_compression_stats` respectively. The views `hypertable_columnstore_settings`, `chunk_columnstore_settings`, and `columnstore_settings` are added as aliases for the corresponding views. We also add aliases for parameters to functions and procedures that take these. - The parameter `timescaledb.enable_columnstore` is an alias for `timescaledb.compress` - The parameter `timescaledb.segmentby` is an alias for `timescaledb.compress_segmentby`. - The parameter `timescaledb.orderby` is an alias for `timescaledb.compress_orderby`.
- Loading branch information
Showing
19 changed files
with
370 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Implements: #7443 Add Hypercore function and view aliases |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,11 +39,24 @@ CREATE OR REPLACE FUNCTION @[email protected]_chunk( | |
hypercore_use_access_method BOOL = NULL | ||
) RETURNS REGCLASS AS '@MODULE_PATHNAME@', 'ts_compress_chunk' LANGUAGE C VOLATILE; | ||
|
||
-- Alias for compress_chunk above. | ||
CREATE OR REPLACE PROCEDURE @[email protected]_to_columnstore( | ||
chunk REGCLASS, | ||
if_not_columnstore BOOLEAN = true, | ||
recompress BOOLEAN = false, | ||
hypercore_use_access_method BOOL = NULL | ||
) AS '@MODULE_PATHNAME@', 'ts_compress_chunk' LANGUAGE C; | ||
|
||
CREATE OR REPLACE FUNCTION @[email protected]_chunk( | ||
uncompressed_chunk REGCLASS, | ||
if_compressed BOOLEAN = true | ||
) RETURNS REGCLASS AS '@MODULE_PATHNAME@', 'ts_decompress_chunk' LANGUAGE C STRICT VOLATILE; | ||
|
||
CREATE OR REPLACE PROCEDURE @[email protected]_to_rowstore( | ||
chunk REGCLASS, | ||
if_columnstore BOOLEAN = true | ||
) AS '@MODULE_PATHNAME@', 'ts_decompress_chunk' LANGUAGE C; | ||
|
||
CREATE OR REPLACE FUNCTION _timescaledb_functions.recompress_chunk_segmentwise( | ||
uncompressed_chunk REGCLASS, | ||
if_compressed BOOLEAN = true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,10 +59,26 @@ RETURNS INTEGER | |
AS '@MODULE_PATHNAME@', 'ts_policy_compression_add' | ||
LANGUAGE C VOLATILE; -- not strict because we need to set different default values for schedule_interval | ||
|
||
CREATE OR REPLACE PROCEDURE @[email protected]_columnstore_policy( | ||
hypertable REGCLASS, | ||
after "any" = NULL, | ||
if_not_exists BOOL = false, | ||
schedule_interval INTERVAL = NULL, | ||
initial_start TIMESTAMPTZ = NULL, | ||
timezone TEXT = NULL, | ||
created_before INTERVAL = NULL, | ||
hypercore_use_access_method BOOL = NULL | ||
) LANGUAGE C AS '@MODULE_PATHNAME@', 'ts_policy_compression_add'; | ||
|
||
CREATE OR REPLACE FUNCTION @[email protected]_compression_policy(hypertable REGCLASS, if_exists BOOL = false) RETURNS BOOL | ||
AS '@MODULE_PATHNAME@', 'ts_policy_compression_remove' | ||
LANGUAGE C VOLATILE STRICT; | ||
|
||
CREATE OR REPLACE PROCEDURE @[email protected]_columnstore_policy( | ||
hypertable REGCLASS, | ||
if_exists BOOL = false | ||
) LANGUAGE C AS '@MODULE_PATHNAME@', 'ts_policy_compression_remove'; | ||
|
||
/* continuous aggregates policy */ | ||
CREATE OR REPLACE FUNCTION @[email protected]_continuous_aggregate_policy( | ||
continuous_aggregate REGCLASS, start_offset "any", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -544,6 +544,25 @@ BEGIN | |
END; | ||
$BODY$ SET search_path TO pg_catalog, pg_temp; | ||
|
||
CREATE OR REPLACE FUNCTION @[email protected]_columnstore_stats (hypertable REGCLASS) | ||
RETURNS TABLE ( | ||
chunk_schema name, | ||
chunk_name name, | ||
compression_status text, | ||
before_compression_table_bytes bigint, | ||
before_compression_index_bytes bigint, | ||
before_compression_toast_bytes bigint, | ||
before_compression_total_bytes bigint, | ||
after_compression_table_bytes bigint, | ||
after_compression_index_bytes bigint, | ||
after_compression_toast_bytes bigint, | ||
after_compression_total_bytes bigint, | ||
node_name name) | ||
LANGUAGE SQL | ||
STABLE STRICT | ||
AS 'SELECT * FROM @[email protected]_compression_stats($1)' | ||
SET search_path TO pg_catalog, pg_temp; | ||
|
||
-- Get compression statistics for a hypertable that has | ||
-- compression enabled | ||
CREATE OR REPLACE FUNCTION @[email protected]_compression_stats (hypertable REGCLASS) | ||
|
@@ -581,6 +600,24 @@ $BODY$ | |
ch.node_name; | ||
$BODY$ SET search_path TO pg_catalog, pg_temp; | ||
|
||
CREATE OR REPLACE FUNCTION @[email protected]_columnstore_stats (hypertable REGCLASS) | ||
RETURNS TABLE ( | ||
total_chunks bigint, | ||
number_compressed_chunks bigint, | ||
before_compression_table_bytes bigint, | ||
before_compression_index_bytes bigint, | ||
before_compression_toast_bytes bigint, | ||
before_compression_total_bytes bigint, | ||
after_compression_table_bytes bigint, | ||
after_compression_index_bytes bigint, | ||
after_compression_toast_bytes bigint, | ||
after_compression_total_bytes bigint, | ||
node_name name) | ||
LANGUAGE SQL | ||
STABLE STRICT | ||
AS 'SELECT * FROM @[email protected]_compression_stats($1)' | ||
SET search_path TO pg_catalog, pg_temp; | ||
|
||
-------------Get index size for hypertables ------- | ||
--schema_name - schema_name for hypertable index | ||
-- index_name - index on hyper table | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,3 +47,70 @@ LANGUAGE C VOLATILE; | |
DROP PROCEDURE IF EXISTS _timescaledb_functions.policy_compression_execute(job_id INTEGER, htid INTEGER, lag ANYELEMENT, maxchunks INTEGER, verbose_log BOOLEAN, recompress_enabled BOOLEAN, use_creation_time BOOLEAN); | ||
|
||
DROP PROCEDURE IF EXISTS _timescaledb_functions.policy_compression(job_id INTEGER, config JSONB); | ||
|
||
CREATE PROCEDURE @[email protected]_to_columnstore( | ||
chunk REGCLASS, | ||
if_not_columnstore BOOLEAN = true, | ||
recompress BOOLEAN = false, | ||
hypercore_use_access_method BOOL = NULL) | ||
AS '@MODULE_PATHNAME@', 'ts_update_placeholder' | ||
LANGUAGE C; | ||
|
||
CREATE PROCEDURE @[email protected]_to_rowstore( | ||
chunk REGCLASS, | ||
if_columnstore BOOLEAN = true) | ||
AS '@MODULE_PATHNAME@', 'ts_update_placeholder' | ||
LANGUAGE C; | ||
|
||
CREATE PROCEDURE @[email protected]_columnstore_policy( | ||
hypertable REGCLASS, | ||
after "any" = NULL, | ||
if_not_exists BOOL = false, | ||
schedule_interval INTERVAL = NULL, | ||
initial_start TIMESTAMPTZ = NULL, | ||
timezone TEXT = NULL, | ||
created_before INTERVAL = NULL, | ||
hypercore_use_access_method BOOL = NULL | ||
) LANGUAGE C AS '@MODULE_PATHNAME@', 'ts_update_placeholder'; | ||
|
||
CREATE PROCEDURE @[email protected]_columnstore_policy( | ||
hypertable REGCLASS, | ||
if_exists BOOL = false | ||
) LANGUAGE C AS '@MODULE_PATHNAME@', 'ts_update_placeholder'; | ||
|
||
CREATE FUNCTION @[email protected]_columnstore_stats (hypertable REGCLASS) | ||
RETURNS TABLE ( | ||
chunk_schema name, | ||
chunk_name name, | ||
compression_status text, | ||
before_compression_table_bytes bigint, | ||
before_compression_index_bytes bigint, | ||
before_compression_toast_bytes bigint, | ||
before_compression_total_bytes bigint, | ||
after_compression_table_bytes bigint, | ||
after_compression_index_bytes bigint, | ||
after_compression_toast_bytes bigint, | ||
after_compression_total_bytes bigint, | ||
node_name name) | ||
LANGUAGE SQL | ||
STABLE STRICT | ||
AS 'SELECT * FROM @[email protected]_compression_stats($1)' | ||
SET search_path TO pg_catalog, pg_temp; | ||
|
||
CREATE FUNCTION @[email protected]_columnstore_stats (hypertable REGCLASS) | ||
RETURNS TABLE ( | ||
total_chunks bigint, | ||
number_compressed_chunks bigint, | ||
before_compression_table_bytes bigint, | ||
before_compression_index_bytes bigint, | ||
before_compression_toast_bytes bigint, | ||
before_compression_total_bytes bigint, | ||
after_compression_table_bytes bigint, | ||
after_compression_index_bytes bigint, | ||
after_compression_toast_bytes bigint, | ||
after_compression_total_bytes bigint, | ||
node_name name) | ||
LANGUAGE SQL | ||
STABLE STRICT | ||
AS 'SELECT * FROM @[email protected]_compression_stats($1)' | ||
SET search_path TO pg_catalog, pg_temp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,3 +44,16 @@ LANGUAGE C VOLATILE; | |
DROP PROCEDURE IF EXISTS _timescaledb_functions.policy_compression_execute(job_id INTEGER, htid INTEGER, lag ANYELEMENT, maxchunks INTEGER, verbose_log BOOLEAN, recompress_enabled BOOLEAN, use_creation_time BOOLEAN, useam BOOLEAN); | ||
|
||
DROP PROCEDURE IF EXISTS _timescaledb_functions.policy_compression(job_id INTEGER, config JSONB); | ||
DROP PROCEDURE IF EXISTS @[email protected]_to_columnstore(REGCLASS, BOOLEAN, BOOLEAN, BOOLEAN); | ||
DROP PROCEDURE IF EXISTS @[email protected]_to_rowstore(REGCLASS, BOOLEAN); | ||
DROP PROCEDURE IF EXISTS @[email protected]_columnstore_policy(REGCLASS, "any", BOOL, INTERVAL, TIMESTAMPTZ, TEXT, INTERVAL, BOOL); | ||
DROP PROCEDURE IF EXISTS @[email protected]_columnstore_policy(REGCLASS, BOOL); | ||
DROP FUNCTION IF EXISTS @[email protected]_columnstore_stats(REGCLASS); | ||
DROP FUNCTION IF EXISTS @[email protected]_columnstore_stats(REGCLASS); | ||
|
||
ALTER EXTENSION timescaledb DROP VIEW timescaledb_information.hypertable_columnstore_settings; | ||
ALTER EXTENSION timescaledb DROP VIEW timescaledb_information.chunk_columnstore_settings; | ||
|
||
DROP VIEW timescaledb_information.hypertable_columnstore_settings; | ||
DROP VIEW timescaledb_information.chunk_columnstore_settings; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.