forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Revert "Doc updates for compression on continuous aggregate f…
…eature"" (github#773) * Revert "Revert "Doc changes for compression on continuous aggregates feature (#666)" (github#730)" This reverts commit ebb417c. * Update timescaledb/how-to-guides/continuous-aggregates/compression-on-continuous-aggregates.md Co-authored-by: Ryan Booz <ryan@timescale.com> * Update api/add_compression_policy.md Co-authored-by: Nuno Santos <nuno@timescale.com> Co-authored-by: Ryan Booz <ryan@timescale.com> Co-authored-by: Jacob Prall <prall.jacob@gmail.com> Co-authored-by: Nuno Santos <nuno@timescale.com>
- Loading branch information
1 parent
2bd0921
commit 473671a
Showing
7 changed files
with
136 additions
and
32 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
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
63 changes: 63 additions & 0 deletions
63
...edb/how-to-guides/continuous-aggregates/compression-on-continuous-aggregates.md
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,63 @@ | ||
# Compression on continuous aggregates | ||
Continuous aggregates are often used to store downsampled historical data. | ||
The historical data is almost never modified or recomputed and is only used | ||
for serving analytic queries. For this use case, it is often beneficial to | ||
store the materialized data in compressed form to save on storage costs. | ||
You can get these cost savings by enabling compression on continuous | ||
aggregates. | ||
|
||
Currently, TimescaleDB does not support refreshing compressed regions of a | ||
continuous aggregate. To do this, you have to manually decompress | ||
the compressed chunk and then execute a `refresh_continuous_aggregate` call. | ||
|
||
## Enable compression on continuous aggregates | ||
You can enable and disable compression on continuous aggregated by setting | ||
`compress` parameter when you alter the view. | ||
|
||
<procedure> | ||
|
||
### Enabling and disabling compression on continuous aggregates | ||
1. For an existing continuous aggregate, at the `psql` prompt, enable | ||
compression: | ||
```sql | ||
ALTER MATERIALIZED VIEW cagg_name set (timescaledb.compress = true); | ||
``` | ||
1. Disable compression: | ||
```sql | ||
ALTER MATERIALIZED VIEW cagg_name set (timescaledb.compress = false); | ||
``` | ||
</procedure> | ||
The decompress command fails if there are compressed chunks associated with the | ||
continuous aggregate. In this case, you need to decompress the chunks, and then | ||
drop any compression policy on the continuous aggregate, before you disable | ||
compression. For more detailed information, see the | ||
[decompress chunks] [decompress-chunks] section: | ||
```sql | ||
SELECT decompress_chunk(c, true) FROM show_chunks('cagg_name') c; | ||
## Compression policies on continuous aggregates | ||
Before setting up a compression policy on a continuous aggregate, you should | ||
set up a refresh policy. The compression policy interval should be set so that | ||
actively refreshed regions are not compressed. This is to prevent refresh | ||
policies from failing. For example, consider a refresh policy like this: | ||
```sql | ||
SELECT add_continuous_aggregate_policy('cagg_name', start_offset=>'30 days', end_offset=>'1 day', '1 h'); | ||
``` | ||
|
||
With this kind of refresh policy, the compression policy needs the `compress_after` | ||
parameter greater than the `refresh_start` parameter of the continuous aggregate policy: | ||
```sql | ||
SELECT add_compression_policy('cagg_name', compress_after=>'45 days'::interval); | ||
``` | ||
|
||
After a chunk is compressed, manual refresh calls that attempt to refresh the | ||
continuous aggregate's compressed region will fail with an error like this: | ||
|
||
```sql | ||
CALL refresh_continuous_aggregate('cagg_name', NULL, now() - '30 days'::interval ); | ||
ERROR: cannot update/delete rows from chunk "_hyper_3_3_chunk" as it is compressed | ||
``` | ||
|
||
[decompress-chunks]: how-to-guides/compression/decompress-chunks.md |
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