1
0
mirror of https://github.com/timescale/timescaledb.git synced 2025-05-18 11:45:11 +08:00

Add function to show compression information

Add a function that can be used on a compressed data value to show
some metadata information, such as the compression algorithm used and
the presence of any null values.
This commit is contained in:
Erik Nordström 2024-06-24 12:13:28 +02:00 committed by Mats Kindahl
parent dbebf58310
commit 19239ff8dd
20 changed files with 240 additions and 124 deletions

1
.unreleased/pr_7126 Normal file

@ -0,0 +1 @@
Implements: #7126 Add functions to show compression info

@ -34,6 +34,11 @@ CREATE OR REPLACE FUNCTION _timescaledb_functions.compressed_data_recv(internal)
AS '@MODULE_PATHNAME@', 'ts_compressed_data_recv'
LANGUAGE C IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION _timescaledb_functions.compressed_data_info(_timescaledb_internal.compressed_data)
RETURNS TABLE (algorithm name, has_nulls bool)
LANGUAGE C STRICT IMMUTABLE
AS '@MODULE_PATHNAME@', 'ts_compressed_data_info';
CREATE OR REPLACE FUNCTION _timescaledb_functions.dimension_info_in(cstring)
RETURNS _timescaledb_internal.dimension_info
LANGUAGE C STRICT IMMUTABLE

@ -0,0 +1,3 @@
CREATE FUNCTION _timescaledb_functions.compressed_data_info(_timescaledb_internal.compressed_data)
RETURNS TABLE (algorithm name, has_nulls bool)
AS 'SELECT NULL,FALSE' LANGUAGE SQL STRICT IMMUTABLE SET search_path = pg_catalog, pg_temp;

@ -0,0 +1 @@
DROP FUNCTION _timescaledb_functions.compressed_data_info(_timescaledb_internal.compressed_data);

@ -66,6 +66,7 @@ CROSSMODULE_WRAPPER(compressed_data_send);
CROSSMODULE_WRAPPER(compressed_data_recv);
CROSSMODULE_WRAPPER(compressed_data_in);
CROSSMODULE_WRAPPER(compressed_data_out);
CROSSMODULE_WRAPPER(compressed_data_info);
CROSSMODULE_WRAPPER(deltadelta_compressor_append);
CROSSMODULE_WRAPPER(deltadelta_compressor_finish);
CROSSMODULE_WRAPPER(gorilla_compressor_append);

@ -118,6 +118,7 @@ typedef struct CrossModuleFunctions
PGFunction compressed_data_recv;
PGFunction compressed_data_in;
PGFunction compressed_data_out;
PGFunction compressed_data_info;
bool (*process_compress_table)(AlterTableCmd *cmd, Hypertable *ht,
WithClauseResult *with_clause_options);
void (*process_altertable_cmd)(Hypertable *ht, const AlterTableCmd *cmd);

@ -40,6 +40,13 @@ typedef struct ArrayCompressed
uint64 alignment_sentinel[FLEXIBLE_ARRAY_MEMBER];
} ArrayCompressed;
bool
array_compressed_has_nulls(const CompressedDataHeader *header)
{
const ArrayCompressed *ac = (const ArrayCompressed *) header;
return ac->has_nulls;
}
static void
pg_attribute_unused() assertions(void)
{

@ -26,6 +26,7 @@ typedef struct ArrayDecompressionIterator ArrayDecompressionIterator;
extern const Compressor array_compressor;
extern bool array_compressed_has_nulls(const CompressedDataHeader *header);
extern Compressor *array_compressor_for_type(Oid element_type);
extern ArrayCompressor *array_compressor_alloc(Oid type_to_compress);
extern void array_compressor_append_null(ArrayCompressor *compressor);

@ -12,6 +12,7 @@
#include <common/base64.h>
#include <funcapi.h>
#include <lib/stringinfo.h>
#include <stdbool.h>
#include <utils/builtins.h>
#include <utils/date.h>
#include <utils/lsyscache.h>
@ -76,6 +77,13 @@ typedef struct ExtendedCompressor
DeltaDeltaCompressor *internal;
} ExtendedCompressor;
bool
deltadelta_compressed_has_nulls(const CompressedDataHeader *header)
{
const DeltaDeltaCompressed *ddc = (const DeltaDeltaCompressed *) header;
return ddc->has_nulls;
}
static void
deltadelta_compressor_append_bool(Compressor *compressor, Datum val)
{

@ -27,6 +27,7 @@ typedef struct DeltaDeltaCompressor DeltaDeltaCompressor;
typedef struct DeltaDeltaCompressed DeltaDeltaCompressed;
typedef struct DeltaDeltaDecompressionIterator DeltaDeltaDecompressionIterator;
extern bool deltadelta_compressed_has_nulls(const CompressedDataHeader *header);
extern Compressor *delta_delta_compressor_for_type(Oid element_type);
extern DeltaDeltaCompressor *delta_delta_compressor_alloc(void);
extern void delta_delta_compressor_append_null(DeltaDeltaCompressor *compressor);

@ -48,6 +48,13 @@ typedef struct DictionaryCompressed
uint64 alignment_sentinel[FLEXIBLE_ARRAY_MEMBER];
} DictionaryCompressed;
bool
dictionary_compressed_has_nulls(const CompressedDataHeader *header)
{
const DictionaryCompressed *dc = (const DictionaryCompressed *) header;
return dc->has_nulls;
}
static void
pg_attribute_unused() assertions(void)
{

@ -23,6 +23,7 @@ typedef struct DictionaryCompressor DictionaryCompressor;
typedef struct DictionaryCompressed DictionaryCompressed;
typedef struct DictionaryDecompressionIterator DictionaryDecompressionIterator;
extern bool dictionary_compressed_has_nulls(const CompressedDataHeader *header);
extern Compressor *dictionary_compressor_for_type(Oid element_type);
extern DictionaryCompressor *dictionary_compressor_alloc(Oid type_to_compress);
extern void dictionary_compressor_append_null(DictionaryCompressor *compressor);

@ -62,6 +62,13 @@ typedef struct CompressedGorillaData
Simple8bRleSerialized *nulls; /* NULL if no nulls */
} CompressedGorillaData;
bool
gorilla_compressed_has_nulls(const CompressedDataHeader *header)
{
const GorillaCompressed *gc = (const GorillaCompressed *) header;
return gc->has_nulls;
}
static void
pg_attribute_unused() assertions(void)
{

@ -71,6 +71,7 @@ typedef struct GorillaCompressor GorillaCompressor;
typedef struct GorillaCompressed GorillaCompressed;
typedef struct GorillaDecompressionIterator GorillaDecompressionIterator;
extern bool gorilla_compressed_has_nulls(const CompressedDataHeader *header);
extern Compressor *gorilla_compressor_for_type(Oid element_type);
extern GorillaCompressor *gorilla_compressor_alloc(void);

@ -46,6 +46,18 @@ static const CompressionAlgorithmDefinition definitions[_END_COMPRESSION_ALGORIT
[COMPRESSION_ALGORITHM_DELTADELTA] = DELTA_DELTA_ALGORITHM_DEFINITION,
};
static const char *compression_algorithm_name[] = {
[_INVALID_COMPRESSION_ALGORITHM] = "INVALID", [COMPRESSION_ALGORITHM_ARRAY] = "ARRAY",
[COMPRESSION_ALGORITHM_DICTIONARY] = "DICTIONARY", [COMPRESSION_ALGORITHM_GORILLA] = "GORILLA",
[COMPRESSION_ALGORITHM_DELTADELTA] = "DELTADELTA",
};
const char *
compression_get_algorithm_name(CompressionAlgorithm alg)
{
return compression_algorithm_name[alg];
}
static Compressor *
compressor_for_type(Oid type)
{
@ -1983,6 +1995,59 @@ tsl_compressed_data_out(PG_FUNCTION_ARGS)
PG_RETURN_CSTRING(encoded);
}
/* create_hypertable record attribute numbers */
enum Anum_compressed_info
{
Anum_compressed_info_algorithm = 1,
Anum_compressed_info_has_nulls,
_Anum_compressed_info_max,
};
#define Natts_compressed_info (_Anum_compressed_info_max - 1)
extern Datum
tsl_compressed_data_info(PG_FUNCTION_ARGS)
{
const CompressedDataHeader *header = (CompressedDataHeader *) PG_GETARG_VARLENA_P(0);
TupleDesc tupdesc;
HeapTuple tuple;
bool has_nulls = false;
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("function returning record called in "
"context that cannot accept type record")));
switch (header->compression_algorithm)
{
case COMPRESSION_ALGORITHM_GORILLA:
has_nulls = gorilla_compressed_has_nulls(header);
break;
case COMPRESSION_ALGORITHM_DICTIONARY:
has_nulls = dictionary_compressed_has_nulls(header);
break;
case COMPRESSION_ALGORITHM_DELTADELTA:
has_nulls = deltadelta_compressed_has_nulls(header);
break;
case COMPRESSION_ALGORITHM_ARRAY:
has_nulls = array_compressed_has_nulls(header);
break;
}
tupdesc = BlessTupleDesc(tupdesc);
Datum values[Natts_compressed_info];
bool nulls[Natts_compressed_info] = { false };
values[AttrNumberGetAttrOffset(Anum_compressed_info_algorithm)] =
CStringGetDatum(compression_get_algorithm_name(header->compression_algorithm));
values[AttrNumberGetAttrOffset(Anum_compressed_info_has_nulls)] = BoolGetDatum(has_nulls);
tuple = heap_form_tuple(tupdesc, values, nulls);
return HeapTupleGetDatum(tuple);
}
extern CompressionStorage
compression_get_toast_storage(CompressionAlgorithm algorithm)
{

@ -296,6 +296,7 @@ extern Datum tsl_compressed_data_send(PG_FUNCTION_ARGS);
extern Datum tsl_compressed_data_recv(PG_FUNCTION_ARGS);
extern Datum tsl_compressed_data_in(PG_FUNCTION_ARGS);
extern Datum tsl_compressed_data_out(PG_FUNCTION_ARGS);
extern Datum tsl_compressed_data_info(PG_FUNCTION_ARGS);
static void
pg_attribute_unused() assert_num_compression_algorithms_sane(void)
@ -320,6 +321,7 @@ pg_attribute_unused() assert_num_compression_algorithms_sane(void)
"number of algorithms have changed, the asserts should be updated");
}
extern const char *compression_get_algorithm_name(CompressionAlgorithm alg);
extern CompressionStorage compression_get_toast_storage(CompressionAlgorithm algo);
extern CompressionAlgorithm compression_get_default_algorithm(Oid typeoid);

@ -144,6 +144,7 @@ CrossModuleFunctions tsl_cm_functions = {
.compressed_data_recv = tsl_compressed_data_recv,
.compressed_data_in = tsl_compressed_data_in,
.compressed_data_out = tsl_compressed_data_out,
.compressed_data_info = tsl_compressed_data_info,
.deltadelta_compressor_append = tsl_deltadelta_compressor_append,
.deltadelta_compressor_finish = tsl_deltadelta_compressor_finish,
.gorilla_compressor_append = tsl_gorilla_compressor_append,

@ -44,9 +44,9 @@ CREATE TABLE base_ints AS SELECT row_number() OVER() as rn, item::bigint FROM (s
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
psql:include/compression_test.sql:7: NOTICE: table "compressed" does not exist, skipping
compressed size
-----------------
1720
algorithm | has_nulls | compressed size
------------+-----------+-----------------
DELTADELTA | f | 1720
(1 row)
?column? | count
@ -78,9 +78,9 @@ INSERT INTO base_ints VALUES (0, NULL), (10, NULL), (10000, NULL);
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
93
algorithm | has_nulls | compressed size
------------+-----------+-----------------
DELTADELTA | t | 93
(1 row)
?column? | count
@ -117,9 +117,9 @@ CREATE TABLE base_ints AS SELECT row_number() OVER() as rn, item::bigint FROM (S
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
45
algorithm | has_nulls | compressed size
------------+-----------+-----------------
DELTADELTA | f | 45
(1 row)
?column? | count
@ -162,9 +162,9 @@ CREATE TABLE base_ints AS SELECT row_number() over () as rn, item FROM
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
184
algorithm | has_nulls | compressed size
------------+-----------+-----------------
DELTADELTA | f | 184
(1 row)
?column? | count
@ -195,9 +195,9 @@ CREATE TABLE base_ints AS SELECT row_number() OVER() as rn, NULLIF(i, 5) item FR
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
69
algorithm | has_nulls | compressed size
------------+-----------+-----------------
DELTADELTA | t | 69
(1 row)
?column? | count
@ -227,9 +227,9 @@ CREATE TABLE base_ints AS SELECT row_number() OVER() as rn, NULLIF(i, 1) item FR
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
69
algorithm | has_nulls | compressed size
------------+-----------+-----------------
DELTADELTA | t | 69
(1 row)
?column? | count
@ -259,9 +259,9 @@ CREATE TABLE base_ints AS SELECT row_number() OVER() as rn, NULLIF(i, 10) item F
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
69
algorithm | has_nulls | compressed size
------------+-----------+-----------------
DELTADELTA | t | 69
(1 row)
?column? | count
@ -291,9 +291,9 @@ CREATE TABLE base_ints AS SELECT row_number() OVER() as rn, NULLIF(NULLIF(NULLIF
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
69
algorithm | has_nulls | compressed size
------------+-----------+-----------------
DELTADELTA | t | 69
(1 row)
?column? | count
@ -334,9 +334,9 @@ SELECT
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
1720
algorithm | has_nulls | compressed size
------------+-----------+-----------------
DELTADELTA | f | 1720
(1 row)
?column? | count
@ -380,9 +380,9 @@ CREATE TABLE base_time AS SELECT row_number() OVER() as rn, item FROM
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
5332
algorithm | has_nulls | compressed size
------------+-----------+-----------------
DELTADELTA | f | 5332
(1 row)
?column? | count
@ -426,9 +426,9 @@ CREATE TABLE base_floats AS SELECT row_number() OVER() as rn, item::float4 FROM
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
1808
algorithm | has_nulls | compressed size
-----------+-----------+-----------------
GORILLA | f | 1808
(1 row)
?column? | count
@ -465,9 +465,9 @@ CREATE TABLE base_floats AS SELECT row_number() OVER() as rn, item::float4 FROM
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
109
algorithm | has_nulls | compressed size
-----------+-----------+-----------------
GORILLA | f | 109
(1 row)
?column? | count
@ -509,9 +509,9 @@ CREATE TABLE base_floats AS SELECT row_number() over () as rn, item FROM
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
152
algorithm | has_nulls | compressed size
-----------+-----------+-----------------
GORILLA | f | 152
(1 row)
?column? | count
@ -542,9 +542,9 @@ CREATE TABLE base_floats AS SELECT row_number() over () as rn, 0::float4 as item
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
160
algorithm | has_nulls | compressed size
-----------+-----------+-----------------
GORILLA | f | 160
(1 row)
?column? | count
@ -575,9 +575,9 @@ CREATE TABLE base_floats AS SELECT row_number() OVER() as rn, NULLIF(i, 5)::floa
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
136
algorithm | has_nulls | compressed size
-----------+-----------+-----------------
GORILLA | t | 136
(1 row)
?column? | count
@ -607,9 +607,9 @@ CREATE TABLE base_floats AS SELECT row_number() OVER() as rn, NULLIF(i, 1)::floa
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
136
algorithm | has_nulls | compressed size
-----------+-----------+-----------------
GORILLA | t | 136
(1 row)
?column? | count
@ -639,9 +639,9 @@ CREATE TABLE base_floats AS SELECT row_number() OVER() as rn, NULLIF(i, 10)::flo
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
136
algorithm | has_nulls | compressed size
-----------+-----------+-----------------
GORILLA | t | 136
(1 row)
?column? | count
@ -671,9 +671,9 @@ CREATE TABLE base_floats AS SELECT row_number() OVER() as rn, NULLIF(NULLIF(NULL
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
136
algorithm | has_nulls | compressed size
-----------+-----------+-----------------
GORILLA | t | 136
(1 row)
?column? | count
@ -717,9 +717,9 @@ CREATE TABLE base_doubles AS SELECT row_number() OVER() as rn, item::double prec
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
1808
algorithm | has_nulls | compressed size
-----------+-----------+-----------------
GORILLA | f | 1808
(1 row)
?column? | count
@ -756,9 +756,9 @@ CREATE TABLE base_doubles AS SELECT row_number() OVER() as rn, item::double prec
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
109
algorithm | has_nulls | compressed size
-----------+-----------+-----------------
GORILLA | f | 109
(1 row)
?column? | count
@ -800,9 +800,9 @@ CREATE TABLE base_doubles AS SELECT row_number() over () as rn, item FROM
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
152
algorithm | has_nulls | compressed size
-----------+-----------+-----------------
GORILLA | f | 152
(1 row)
?column? | count
@ -833,9 +833,9 @@ CREATE TABLE base_doubles AS SELECT row_number() over () as rn, 0::FLOAT(50) as
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
160
algorithm | has_nulls | compressed size
-----------+-----------+-----------------
GORILLA | f | 160
(1 row)
?column? | count
@ -866,9 +866,9 @@ CREATE TABLE base_doubles AS SELECT row_number() OVER() as rn, NULLIF(i, 5)::DOU
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
136
algorithm | has_nulls | compressed size
-----------+-----------+-----------------
GORILLA | t | 136
(1 row)
?column? | count
@ -898,9 +898,9 @@ CREATE TABLE base_doubles AS SELECT row_number() OVER() as rn, NULLIF(i, 1)::DOU
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
136
algorithm | has_nulls | compressed size
-----------+-----------+-----------------
GORILLA | t | 136
(1 row)
?column? | count
@ -930,9 +930,9 @@ CREATE TABLE base_doubles AS SELECT row_number() OVER() as rn, NULLIF(i, 10)::DO
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
136
algorithm | has_nulls | compressed size
-----------+-----------+-----------------
GORILLA | t | 136
(1 row)
?column? | count
@ -962,9 +962,9 @@ CREATE TABLE base_doubles AS SELECT row_number() OVER() as rn, NULLIF(NULLIF(NUL
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
136
algorithm | has_nulls | compressed size
-----------+-----------+-----------------
GORILLA | t | 136
(1 row)
?column? | count
@ -1009,9 +1009,9 @@ CREATE TABLE base_texts AS SELECT row_number() OVER() as rn, item::text FROM
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
4305
algorithm | has_nulls | compressed size
-----------+-----------+-----------------
ARRAY | f | 4305
(1 row)
?column? | count
@ -1049,9 +1049,9 @@ CREATE TABLE base_texts AS SELECT row_number() OVER() as rn, item::text FROM
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
605
algorithm | has_nulls | compressed size
------------+-----------+-----------------
DICTIONARY | f | 605
(1 row)
?column? | count
@ -1082,9 +1082,9 @@ CREATE TABLE base_texts AS SELECT row_number() OVER() as rn, item::text FROM (SE
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
39
algorithm | has_nulls | compressed size
-----------+-----------+-----------------
ARRAY | f | 39
(1 row)
?column? | count
@ -1125,9 +1125,9 @@ SELECT pg_total_relation_size(reltoastrelid)
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
1100092
algorithm | has_nulls | compressed size
-----------+-----------+-----------------
ARRAY | f | 1100092
(1 row)
?column? | count
@ -1158,9 +1158,9 @@ CREATE TABLE base_texts AS SELECT row_number() OVER() as rn, NULLIF(i, 5)::TEXT
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
187
algorithm | has_nulls | compressed size
------------+-----------+-----------------
DICTIONARY | t | 187
(1 row)
?column? | count
@ -1190,9 +1190,9 @@ CREATE TABLE base_texts AS SELECT row_number() OVER() as rn, NULLIF(i, 1)::TEXT
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
179
algorithm | has_nulls | compressed size
------------+-----------+-----------------
DICTIONARY | t | 179
(1 row)
?column? | count
@ -1222,9 +1222,9 @@ CREATE TABLE base_texts AS SELECT row_number() OVER() as rn, NULLIF(i, 10)::TEXT
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
178
algorithm | has_nulls | compressed size
------------+-----------+-----------------
DICTIONARY | t | 178
(1 row)
?column? | count
@ -1254,9 +1254,9 @@ CREATE TABLE base_texts AS SELECT row_number() OVER() as rn, NULLIF(NULLIF(NULLI
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
189
algorithm | has_nulls | compressed size
------------+-----------+-----------------
DICTIONARY | t | 189
(1 row)
?column? | count
@ -1301,9 +1301,9 @@ CREATE TABLE base_texts AS SELECT row_number() OVER() as rn, item::text FROM
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
356
algorithm | has_nulls | compressed size
-----------+-----------+-----------------
ARRAY | f | 356
(1 row)
?column? | count
@ -1340,9 +1340,9 @@ CREATE TABLE base_texts AS SELECT row_number() OVER() as rn, item::text FROM (SE
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
39
algorithm | has_nulls | compressed size
-----------+-----------+-----------------
ARRAY | f | 39
(1 row)
?column? | count
@ -1383,9 +1383,9 @@ SELECT pg_total_relation_size(reltoastrelid)
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
1100092
algorithm | has_nulls | compressed size
-----------+-----------+-----------------
ARRAY | f | 1100092
(1 row)
?column? | count
@ -1416,9 +1416,9 @@ CREATE TABLE base_texts AS SELECT row_number() OVER() as rn, NULLIF(i, 5)::TEXT
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
80
algorithm | has_nulls | compressed size
-----------+-----------+-----------------
ARRAY | t | 80
(1 row)
?column? | count
@ -1448,9 +1448,9 @@ CREATE TABLE base_texts AS SELECT row_number() OVER() as rn, NULLIF(i, 1)::TEXT
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
80
algorithm | has_nulls | compressed size
-----------+-----------+-----------------
ARRAY | t | 80
(1 row)
?column? | count
@ -1480,9 +1480,9 @@ CREATE TABLE base_texts AS SELECT row_number() OVER() as rn, NULLIF(i, 10)::TEXT
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
79
algorithm | has_nulls | compressed size
-----------+-----------+-----------------
ARRAY | t | 79
(1 row)
?column? | count
@ -1512,9 +1512,9 @@ CREATE TABLE base_texts AS SELECT row_number() OVER() as rn, NULLIF(NULLIF(NULLI
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\set ECHO errors
compressed size
-----------------
74
algorithm | has_nulls | compressed size
-----------+-----------+-----------------
ARRAY | t | 74
(1 row)
?column? | count

@ -51,6 +51,7 @@ ORDER BY pronamespace::regnamespace::text COLLATE "C", p.oid::regprocedure::text
_timescaledb_functions.chunks_local_size(name,name)
_timescaledb_functions.compressed_chunk_local_stats(name,name)
_timescaledb_functions.compressed_data_in(cstring)
_timescaledb_functions.compressed_data_info(_timescaledb_internal.compressed_data)
_timescaledb_functions.compressed_data_out(_timescaledb_internal.compressed_data)
_timescaledb_functions.compressed_data_recv(internal)
_timescaledb_functions.compressed_data_send(_timescaledb_internal.compressed_data)

@ -6,7 +6,9 @@
DROP TABLE IF EXISTS compressed;
CREATE TABLE compressed AS SELECT :COMPRESSION_CMD AS c FROM (:QUERY) AS sub;
SELECT pg_column_size(c) as "compressed size" FROM compressed;
SELECT (_timescaledb_functions.compressed_data_info(c)).*,
pg_column_size(c) as "compressed size"
FROM compressed;
--rewrite table (needed to make sure the compressed data does not reference toast table of original)
CREATE TABLE temp AS SELECT * FROM :TABLE_NAME;