diff --git a/api/hypercore/add_columnstore_policy.md b/api/hypercore/add_columnstore_policy.md index a024607bbe..b8d08be88a 100644 --- a/api/hypercore/add_columnstore_policy.md +++ b/api/hypercore/add_columnstore_policy.md @@ -1,29 +1,71 @@ --- -api_name: add_compression_policy() -excerpt: Add policy to schedule automatic compression of chunks -topics: [compression, jobs] -keywords: [compression, policies] +api_name: add_columnstore_policy() +excerpt: Set a policy to automatically move chunks in a hypertable to the columnstore when they reach a given age. +topics: [columnstore, jobs] +keywords: [columnstore, policies] tags: [scheduled jobs, background jobs, automation framework] api: license: community type: function --- -# add_compression_policy() +# add_columnstore_policy() -Set a policy where the system compresses a chunk automatically in the background after -it reaches a given age. +Set a policy to automatically move chunks in a hypertable to the columnstore when they reach a given age. -Compression policies can only be created on hypertables or continuous aggregates -that already have compression enabled. To set `timescaledb.compress` and other -configuration parameters for hypertables, use the -[`ALTER TABLE`][compression_alter-table] -command. To enable compression on continuous aggregates, use the -[`ALTER MATERIALIZED VIEW`][compression_continuous-aggregate] -command. To view the policies that you set or the policies that already exist, -see [informational views][informational-views]. +## Samples -## Required arguments +To create a columnstore policy: + +1. **Enable columnstore** + + * [For a hypertable][compression_alter-table] + ```sql + ALTER TABLE stocks_real_time SET (timescaledb.enable_columnstore = true, timescaledb.segmentby = 'symbol'); + ``` + * [For a continuous aggregate][compression_continuous-aggregate] + ```sql + ALTER MATERIALIZED VIEW stock_candlestick_daily set (timescaledb.enable_columnstore = true, timescaledb.segmentby = 'symbol' ); + ``` + +1. **Add a policy to move chunks to the columnstore at a specific time interval** + + For example: + + * 60 days after the data was added to the table: + ``` sql + SELECT add_columnstore_policy('stocks_real_time', compress_after => INTERVAL '60d'); + ``` + * 3 months prior to the moment you run the query: + + ``` sql + SELECT add_columnstore_policy('stocks_real_time', compress_created_before => INTERVAL '3 months'); + ``` + * With an integer-based time column: + + ``` sql + SELECT add_columnstore_policy('table_with_bigint_time', BIGINT '600000'); + ``` + * Older than eight weeks: + + ``` sql + SELECT add_columnstore_policy('cpu_weekly', INTERVAL '8 weeks'); + ``` + +1. **View the policies that you set or the policies that already exist** + + See [informational views][informational-views]. + + + +## Arguments + + +| Name | Type | Default | Required | Description | +|-------------|------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------|------------------------------------------------| +|`hypertable`|REGCLASS| | | Name of the hypertable or continuous aggregate | +|`compress_after`|INTERVAL or INTEGER| | | The age after which the policy job compresses chunks. `compress_after` is calculated relative to the current time, so chunks containing data older than `now - {compress_after}::interval` are compressed. This argument is mutually exclusive with `compress_created_before`. | +|`compress_created_before`|INTERVAL| | | Chunks with creation time older than this cut-off point are compressed. The cut-off point is computed as `now() - compress_created_before`. Defaults to `NULL`. Not supported for continuous aggregates yet. This argument is mutually exclusive with `compress_after`. | |Name|Type|Description| |-|-|-| @@ -53,37 +95,7 @@ on the type of the time column of the hypertable or continuous aggregate: -## Sample usage - -Add a policy to compress chunks older than 60 days on the `cpu` hypertable. - -``` sql -SELECT add_compression_policy('cpu', compress_after => INTERVAL '60d'); -``` - -Add a policy to compress chunks created 3 months before on the 'cpu' hypertable. - -``` sql -SELECT add_compression_policy('cpu', compress_created_before => INTERVAL '3 months'); -``` - -Note above that when `compress_after` is used then the time data range -present in the partitioning time column is used to select the target -chunks. Whereas, when `compress_created_before` is used then the chunks -which were created 3 months ago are selected. - -Add a compress chunks policy to a hypertable with an integer-based time column: - -``` sql -SELECT add_compression_policy('table_with_bigint_time', BIGINT '600000'); -``` - -Add a policy to compress chunks of a continuous aggregate called `cpu_weekly`, that are -older than eight weeks: -``` sql -SELECT add_compression_policy('cpu_weekly', INTERVAL '8 weeks'); -``` [compression_alter-table]: /api/:currentVersion:/compression/alter_table_compression/ [compression_continuous-aggregate]: /api/:currentVersion:/continuous-aggregates/alter_materialized_view/ diff --git a/api/hypercore/chunk_columnstore_settings.md b/api/hypercore/chunk_columnstore_settings.md index 240e558255..05bc5c2809 100644 --- a/api/hypercore/chunk_columnstore_settings.md +++ b/api/hypercore/chunk_columnstore_settings.md @@ -1,46 +1,46 @@ --- -api_name: timescaledb_information.chunk_compression_settings +api_name: timescaledb_information.chunk_columnstore_settings excerpt: Get information about compression settings for all chunks topics: [information, compression, chunk] -keywords: [compression, chunk, information] -tags: [chunk compression, compression settings] +keywords: [columnstore, chunk, information] +tags: [chunk, columnstore settings] api: license: community type: view --- -# timescaledb_information.chunk_compression_settings +# timescaledb_information.chunk_columnstore_settings -Show the compression settings for each chunk that has compression enabled. +Retrieve information about each chunk in the columnstore. -### Arguments +### Samples -|Name|Type|Description| -|-|-|-| -|`hypertable`|`REGCLASS`|Hypertable which has compression enabled| -|`chunk`|`REGCLASS`|Chunk which has compression enabled| -|`segmentby`|`TEXT`|List of columns used for segmenting the compressed data| -|`orderby`|`TEXT`| List of columns used for ordering compressed data along with ordering and NULL ordering information| +* Show settings for all chunks in the columnstore: -### Sample use + ```sql + SELECT * FROM timescaledb_information.chunk_columnstore_settings + + hypertable | chunk | segmentby | orderby + ------------+-------+-----------+--------- + measurements | _timescaledb_internal._hyper_1_1_chunk| | "time" DESC + ``` -Show compression settings for all chunks: +* Find all chunk compression settings for a specific hypertable: -```sql -SELECT * FROM timescaledb_information.chunk_compression_settings' -hypertable | measurements -chunk | _timescaledb_internal._hyper_1_1_chunk -segmentby | -orderby | "time" DESC -``` + ```sql + SELECT * FROM timescaledb_information.chunk_columnstore_settings WHERE hypertable::TEXT LIKE 'metrics'; + + hypertable | chunk | segmentby | orderby + ------------+-------+-----------+--------- + metrics | _timescaledb_internal._hyper_2_3_chunk | metric_id | "time" + ``` -Find all chunk compression settings for a specific hypertable: +## Arguments -```sql -SELECT * FROM timescaledb_information.chunk_compression_settings WHERE hypertable::TEXT LIKE 'metrics'; -hypertable | metrics -chunk | _timescaledb_internal._hyper_2_3_chunk -segmentby | metric_id -orderby | "time" -``` +| Name | Type | Default | Required | Description | +|-------------|------------------|--------|--------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------| +|`hypertable`|`REGCLASS`|-|✖| The name of a hypertable in the columnstore | +|`chunk`|`REGCLASS`|-|✖| The name of a chunk in `hypertable` | +|`segmentby`|`TEXT`|-|✖| A list of columns used to segment `hypertable` | +|`orderby`|`TEXT`|-|✖| A list of columns used to order data in `hypertable`. Along with ordering and NULL ordering information. IAIN, I don't understand the second sentence. | diff --git a/api/hypercore/columnstore_settings.md b/api/hypercore/columnstore_settings.md index ec148588e3..8c35512a39 100644 --- a/api/hypercore/columnstore_settings.md +++ b/api/hypercore/columnstore_settings.md @@ -11,9 +11,10 @@ api: import DeprecationNotice from "versionContent/_partials/_deprecated.mdx"; -# timescaledb_information.compression_settings +# timescaledb_information.columnstore_settings -This view exists for backwards compatibility. The supported views to retrieve information about compression are: +This view exists for backwards compatibility. Best practice is to use the following views to retrieve +information about columnstore_settings: - [timescaledb_information.hypertable_compression_settings][hypertable_compression_settings] - [timescaledb_information.chunk_compression_settings][chunk_compression_settings]. @@ -21,7 +22,6 @@ This view exists for backwards compatibility. The supported views to retrieve in - Get information about compression-related settings for hypertables. Each row of the view provides information about individual `orderby` and `segmentby` columns used by compression. diff --git a/api/hypercore/hypertable_columnstore_settings.md b/api/hypercore/hypertable_columnstore_settings.md index e78fce8295..b8585eb6af 100644 --- a/api/hypercore/hypertable_columnstore_settings.md +++ b/api/hypercore/hypertable_columnstore_settings.md @@ -9,9 +9,9 @@ api: type: view --- -# timescaledb_information.hypertable_compression_settings +# timescaledb_information.hypertable_columnstore_settings -Returns information about the compression settings for each hypertable in the columnstore. +Retrieve information about the settings for each hypertable in the columnstore. ### Arguments @@ -22,19 +22,19 @@ Returns information about the compression settings for each hypertable in the co |`orderby`|`TEXT`| List of columns used for ordering compressed data along with ordering and NULL ordering information| |`compress_interval_length`|`TEXT`|Interval used for [rolling up chunks during compression][rollup-compression]| -### Sample use +### Samples -Show compression settings for all hypertables: +Show columnstore settings for all hypertables: ```sql -SELECT * FROM timescaledb_information.hypertable_compression_settings' +SELECT * FROM timescaledb_information.hypertable_columnstore_settings' hypertable | measurements segmentby | orderby | "time" DESC compress_interval_length | ``` -Find compression settings for a specific hypertable: +Retrieve columnstore settings for a specific hypertable: ```sql SELECT * FROM timescaledb_information.hypertable_compression_settings WHERE hypertable::TEXT LIKE 'metrics';