mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-22 22:11:29 +08:00
Unless otherwise listed, the TODO was converted to a comment or put into an issue tracker. test/sql/ - triggers.sql: Made required change tsl/test/ - CMakeLists.txt: TODO complete - bgw_policy.sql: TODO complete - continuous_aggs_materialize.sql: TODO complete - compression.sql: TODO complete - compression_algos.sql: TODO complete tsl/src/ - compression/compression.c: - row_compressor_decompress_row: Expected complete - compression/dictionary.c: FIXME complete - materialize.c: TODO complete - reorder.c: TODO complete - simple8b_rle.h: - compressor_finish: Removed (obsolete) src/ - extension.c: Removed due to age - adts/simplehash.h: TODOs are from copied Postgres code - adts/vec.h: TODO is non-significant - planner.c: Removed - process_utility.c - process_altertable_end_subcmd: Removed (PG will handle case)
1267 lines
98 KiB
Plaintext
1267 lines
98 KiB
Plaintext
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
--install necessary functions for tests
|
|
\c :TEST_DBNAME :ROLE_SUPERUSER
|
|
CREATE OR REPLACE FUNCTION ts_test_compression() RETURNS VOID
|
|
AS :TSL_MODULE_PATHNAME LANGUAGE C VOLATILE;
|
|
\ir include/compression_utils.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
\c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER
|
|
------------------
|
|
-- C unit tests --
|
|
------------------
|
|
SELECT ts_test_compression();
|
|
ts_test_compression
|
|
---------------------
|
|
|
|
(1 row)
|
|
|
|
\ir include/rand_generator.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
--------------------------
|
|
-- cheap rand generator --
|
|
--------------------------
|
|
create table rand_minstd_state(i bigint);
|
|
create function rand_minstd_advance(bigint) returns bigint
|
|
language sql immutable as
|
|
$$
|
|
select (16807 * $1) % 2147483647
|
|
$$;
|
|
create function gen_rand_minstd() returns bigint
|
|
language sql security definer as
|
|
$$
|
|
update rand_minstd_state set i = rand_minstd_advance(i) returning i
|
|
$$;
|
|
-- seed the random num generator
|
|
insert into rand_minstd_state values (321);
|
|
------------------------
|
|
-- BIGINT Compression --
|
|
------------------------
|
|
SELECT
|
|
$$
|
|
select item from base_ints order by rn
|
|
$$ AS "QUERY"
|
|
\gset
|
|
\set TABLE_NAME base_ints
|
|
\set TYPE BIGINT
|
|
\set COMPRESSION_CMD _timescaledb_internal.compress_deltadelta(item)
|
|
\set DECOMPRESS_FORWARD_CMD _timescaledb_internal.decompress_forward(c::_timescaledb_internal.compressed_data, NULL::BIGINT)
|
|
\set DECOMPRESS_REVERSE_CMD _timescaledb_internal.decompress_reverse(c::_timescaledb_internal.compressed_data, NULL::BIGINT)
|
|
-- random order
|
|
CREATE TABLE base_ints AS SELECT row_number() OVER() as rn, item::bigint FROM (select sub.item from (SELECT generate_series(1, 1000) item) as sub ORDER BY gen_rand_minstd()) sub;
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- 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
|
|
-----------------
|
|
1728
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
DROP TABLE base_ints;
|
|
-- ascending order with nulls
|
|
CREATE TABLE base_ints AS SELECT row_number() OVER() as rn, item::bigint FROM (SELECT generate_series(1, 1000) item) sub;
|
|
INSERT INTO base_ints VALUES (0, NULL), (10, NULL), (10000, NULL);
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
93
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
SELECT c ints_text FROM compressed;
|
|
ints_text
|
|
--------------------------------------------------------------------------------------------------------------------------
|
|
BAEAAAAAAAAD6AAAAAAAAAABAAAD6AAAAAIAAAAAAAAA8gAAAAAAAAACAAA8gAAAAAAAAAPrAAAAAwAAAAAAAAHxAAAAAAAABAEAADqgAAAAAAAAAAAAAAAB
|
|
(1 row)
|
|
|
|
DROP TABLE base_ints;
|
|
-- single element
|
|
CREATE TABLE base_ints AS SELECT row_number() OVER() as rn, item::bigint FROM (SELECT generate_series(1, 1) item) sub;
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
45
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
DROP TABLE base_ints;
|
|
-- really big deltas
|
|
SELECT 9223372036854775807 as big_int_max \gset
|
|
SELECT -9223372036854775808 as big_int_min \gset
|
|
CREATE TABLE base_ints AS SELECT row_number() over () as rn, item FROM
|
|
(
|
|
VALUES
|
|
--big deltas
|
|
(0), (:big_int_max), (:big_int_min), (:big_int_max), (:big_int_min),
|
|
(0), (:big_int_min), (32), (5), (:big_int_min), (-52), (:big_int_max),
|
|
(1000),
|
|
--big delta_deltas
|
|
(0), (:big_int_max), (:big_int_max), (:big_int_min), (:big_int_min), (:big_int_max), (:big_int_max),
|
|
(0), (:big_int_max-1), (:big_int_max-1), (:big_int_min), (:big_int_min), (:big_int_max-1), (:big_int_max-1)
|
|
) as t(item);
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
184
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
DROP TABLE base_ints;
|
|
-- NULLs
|
|
CREATE TABLE base_ints AS SELECT row_number() OVER() as rn, NULLIF(i, 5) item FROM generate_series(1::BIGINT, 10) i;
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
69
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
DROP TABLE base_ints;
|
|
CREATE TABLE base_ints AS SELECT row_number() OVER() as rn, NULLIF(i, 1) item FROM generate_series(1::BIGINT, 10) i;
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
69
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
DROP TABLE base_ints;
|
|
CREATE TABLE base_ints AS SELECT row_number() OVER() as rn, NULLIF(i, 10) item FROM generate_series(1::BIGINT, 10) i;
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
69
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
DROP TABLE base_ints;
|
|
CREATE TABLE base_ints AS SELECT row_number() OVER() as rn, NULLIF(NULLIF(NULLIF(NULLIF(i, 2), 4), 5), 8) item FROM generate_series(1::BIGINT, 10) i;
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
69
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
DROP TABLE base_ints;
|
|
------------------------
|
|
-- INT Compression --
|
|
------------------------
|
|
CREATE TABLE base_ints AS SELECT row_number() OVER() as rn, item::int FROM (select sub.item from (SELECT generate_series(1, 1000) item) as sub ORDER BY gen_rand_minstd()) sub;
|
|
SELECT
|
|
$$
|
|
select item::bigint from base_ints order by rn
|
|
$$ AS "QUERY"
|
|
\gset
|
|
\set TABLE_NAME base_ints
|
|
\set TYPE BIGINT
|
|
\set COMPRESSION_CMD _timescaledb_internal.compress_deltadelta(item::bigint)
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
1728
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
DROP TABLE base_ints;
|
|
-----------------------------
|
|
-- TIMESTAMPTZ Compression --
|
|
-----------------------------
|
|
SELECT
|
|
$$
|
|
select item from base_time order by rn
|
|
$$ AS "QUERY"
|
|
\gset
|
|
\set TYPE TIMESTAMPTZ
|
|
\set TABLE_NAME base_time
|
|
\set COMPRESSION_CMD _timescaledb_internal.compress_deltadelta(item)
|
|
\set DECOMPRESS_FORWARD_CMD _timescaledb_internal.decompress_forward(c::_timescaledb_internal.compressed_data, NULL::TIMESTAMPTZ)
|
|
\set DECOMPRESS_REVERSE_CMD _timescaledb_internal.decompress_reverse(c::_timescaledb_internal.compressed_data, NULL::TIMESTAMPTZ)
|
|
CREATE TABLE base_time AS SELECT row_number() OVER() as rn, item FROM
|
|
(select sub.item from (SELECT generate_series('2018-03-02 1:00'::TIMESTAMPTZ, '2018-03-28 1:00', '1 hour') item) as sub ORDER BY gen_rand_minstd()) sub;
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
5332
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
DROP TABLE base_time;
|
|
------------------------
|
|
-- DOUBLE Compression --
|
|
------------------------
|
|
SELECT
|
|
$$
|
|
select item from base_doubles order by rn
|
|
$$ AS "QUERY"
|
|
\gset
|
|
\set TABLE_NAME base_doubles
|
|
SELECT 'DOUBLE PRECISION' as "TYPE" \gset
|
|
\set COMPRESSION_CMD _timescaledb_internal.compress_gorilla(item)
|
|
SELECT '_timescaledb_internal.decompress_forward(c::_timescaledb_internal.compressed_data, NULL::DOUBLE PRECISION)' AS "DECOMPRESS_FORWARD_CMD" \gset
|
|
SELECT '_timescaledb_internal.decompress_reverse(c::_timescaledb_internal.compressed_data, NULL::DOUBLE PRECISION)' AS "DECOMPRESS_REVERSE_CMD" \gset
|
|
CREATE TABLE base_doubles AS SELECT row_number() OVER() as rn, item::double precision FROM
|
|
(select sub.item from (SELECT generate_series(1, 1000) item) as sub ORDER BY gen_rand_minstd()) sub;
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
1808
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
SELECT c gorilla_text FROM compressed;
|
|
gorilla_text
|
|
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
AwBAe9AAAAAAAAAAA+gAAAABAAAAAAAAAA8AAD6AAAAAAQAAA+gAAAAEAAAAAAAA8f8AAAQQAAAAAQAAG/AAAAAAAAAAAAAAGFsAABqAAAAAAAAAAAcwggooggggggGIIIIIIINMICETDCCCCyCCggooohAgwo0IINIIIIONIDCSSiDEDjDTAAAgwgowEEgAAABIAAAABQAAAAAABURFBrWoSpTWsZLd2bx925R8edzHeqXWhNKZ2TdVfcjd3WcGpYk9HNOs6QAAAMg0ZejfXftmAzFj/WfPPef8X/X/XqufB+P/kcu7vc2E7EGeb/N8d9n+P/++mn+B3y757qdTc+cMO+/sDwh6c9yabt/ee8PSPvf38J84bk1v2L7sFUj/oFG+Q2ASrf4vMRXZNgPQN94+09MyHUZYO9gq4Jvr4y5i7Dw7cIjFjviIRgKwBwVIasMJB8HUFJCaHALneS4lwMYLAFW+ee4vrX7kFxiDP/u/0NB883YajtB5g6gHz818c85BAJIaaQGWJvBYhH6MBUAVe0jYe/AugeoDX6oIB3YF3fkPxB/MLxgAEd5QnMVE8a7OdZhE/F31P9uG/ToYkDOLILqkMttQd0MIDrzF4NDDgEfXaYw5IBDyd7gqoZM6e+nyi+kTXR+olEVkvR6Y+VelPkNFPXwDgG904yUGIA8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ODiEVDr/hRQXIAqQMrnB1sDAB4BXhwNyOxDpBDr3l7u/72w/teyeCYOu0hJzMKHk6cIUAJenwKYVwWfpQc0JGGZFo+OIWEQnkEy3uL81+5AxtMpQI1Ox/sM+IR/q/wp8U9bHJcvAegKULJCj3MH+AU/mGFHAC2nzXcIS0EIGQBJfe+7AwgnH5QEO5MqcB+FQc79DCgB93kAOH634D/VCgBbBaf+wIwaQP3wH5loq2XgVFDaRwR3bXmrqjg1uq1bAQMMghQ3Qay1Giw0QZ68hh4AzbH9VAD3kyKUDPymLiZcQPATOtHTgqpnD71/+Dn+zRCaeizhyzMgDANwE7CQB2QjdCwvoHAC8FO5FzyHUeeuJRLg+gSELvepP8E8AxgIA87vA7XoEOeFxIQJI6GB3gHHKQcHl0PnhUMG142fA9AiPtv7Idzon2/sqGMDqUXU/gnwhYDTmcB05JZWCk8mxH3iA/gK0I161Tp1aBmAHOWwQgLH8/yv/eAX9O8jf//uILISNva5mDg+U4eu8CoFeXrU2mFTIX9pDSeZBTcxRGgOT4CZz3/4p+wA2CUDDvqfrFN3TuQvKP/Oi0Ipf3AAf78fnyYDd0E4CaEG9feApYIX/QLz1eHn0yHrDL5rMpPzMK0AAPgP65hhGA==
|
|
(1 row)
|
|
|
|
DROP TABLE base_doubles;
|
|
-- single element
|
|
CREATE TABLE base_doubles AS SELECT row_number() OVER() as rn, item::double precision FROM (SELECT generate_series(1, 1) item) sub;
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
109
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
DROP TABLE base_doubles;
|
|
--special values
|
|
CREATE TABLE base_doubles AS SELECT row_number() over () as rn, item FROM
|
|
(
|
|
VALUES
|
|
--special
|
|
(0::double precision), ('Infinity'), ('-Infinity'), ('NaN'),
|
|
--big deltas
|
|
(0), ('Infinity'), ('-Infinity'), ('Infinity'), ('-Infinity'),
|
|
(0), ('-Infinity'), (32), (5), ('-Infinity'), (-52), ('Infinity'),
|
|
(1000),
|
|
--big delta_deltas
|
|
(0), ('Infinity'), ('Infinity'), ('-Infinity'), ('-Infinity'), ('Infinity'), ('Infinity')
|
|
) as t(item);
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
152
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
DROP TABLE base_doubles;
|
|
-- all 0s
|
|
CREATE TABLE base_doubles AS SELECT row_number() over () as rn, 0::FLOAT(50) as item FROM (SELECT generate_series(1, 1000) ) j;
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
160
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
DROP TABLE base_doubles;
|
|
-- NULLs
|
|
CREATE TABLE base_doubles AS SELECT row_number() OVER() as rn, NULLIF(i, 5)::DOUBLE PRECISION item FROM generate_series(1, 10) i;
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
136
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
DROP TABLE base_doubles;
|
|
CREATE TABLE base_doubles AS SELECT row_number() OVER() as rn, NULLIF(i, 1)::DOUBLE PRECISION item FROM generate_series(1, 10) i;
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
136
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
DROP TABLE base_doubles;
|
|
CREATE TABLE base_doubles AS SELECT row_number() OVER() as rn, NULLIF(i, 10)::DOUBLE PRECISION item FROM generate_series(1, 10) i;
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
136
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
DROP TABLE base_doubles;
|
|
CREATE TABLE base_doubles AS SELECT row_number() OVER() as rn, NULLIF(NULLIF(NULLIF(NULLIF(i, 2), 4), 5), 8)::DOUBLE PRECISION item FROM generate_series(1, 10) i;
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
136
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
DROP TABLE base_doubles;
|
|
------------------------
|
|
-- Dictionary Compression --
|
|
------------------------
|
|
SELECT
|
|
$$
|
|
select item from base_texts order by rn
|
|
$$ AS "QUERY"
|
|
\gset
|
|
\set TABLE_NAME base_texts
|
|
SELECT 'TEXT' as "TYPE" \gset
|
|
\set COMPRESSION_CMD _timescaledb_internal.compress_dictionary(item)
|
|
\set DECOMPRESS_FORWARD_CMD _timescaledb_internal.decompress_forward(c::_timescaledb_internal.compressed_data, NULL::TEXT)
|
|
\set DECOMPRESS_REVERSE_CMD _timescaledb_internal.decompress_reverse(c::_timescaledb_internal.compressed_data, NULL::TEXT)
|
|
-- high cardinality
|
|
CREATE TABLE base_texts AS SELECT row_number() OVER() as rn, item::text FROM
|
|
(select sub.item from (SELECT generate_series(1, 1000) item) as sub ORDER BY gen_rand_minstd()) sub;
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
4289
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
SELECT c from compressed;
|
|
c
|
|
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
AQBwZ19jYXRhbG9nAHRleHQAAAEAAAPoAAAAAzM0OQAAAAM4NjMAAAACNDUAAAADOTc4AAAAAzEwMQAAAAM1MjcAAAADOTUxAAAAAzYyOQAAAAM2NTcAAAADMjU5AAAAAzU5OQAAAAM1MzAAAAADMTI2AAAAAzc1OAAAAAI2MQAAAAMyMjIAAAACNTkAAAADMzUyAAAAAzI3OQAAAAM0NzQAAAADMzg5AAAAAzUxMAAAAAI2MgAAAAM2OTYAAAABMwAAAAM3MDAAAAADMzE3AAAAAzM3OAAAAAM0MTEAAAADNjI0AAAAAzQ4MQAAAAM3NzEAAAADMjE1AAAAAzgxNwAAAAM3NzIAAAADOTA0AAAAAzU5NQAAAAM3NTYAAAADNjE3AAAAAzk1MwAAAAMyMTAAAAADODIzAAAAAzUzNAAAAAM2NTQAAAADMjAxAAAAAjE2AAAAAzkzNgAAAAM3ODQAAAADODQzAAAAAzUwNgAAAAM2NzMAAAADMzYzAAAAAzYzNgAAAAI1OAAAAAM1MDMAAAADMTk1AAAAAzU1MwAAAAMxNDcAAAADOTAxAAAAAzIyMQAAAAMxMjEAAAADNjYxAAAAAzU4NAAAAAM2MDkAAAADNDQ2AAAAAzkwNgAAAAM2MDcAAAADMzYxAAAAAzY0NwAAAAM4MDgAAAADOTc5AAAAAzQ4MAAAAAM5MjMAAAADNzYxAAAAAzI0MwAAAAMzMjEAAAADMjE3AAAAAjM5AAAAAzYwMwAAAAMzNjkAAAADOTM4AAAAAzcyMQAAAAI4MgAAAAM4ODkAAAADMjM2AAAAAzk1NAAAAAMxMTUAAAADNzgyAAAAAzk3NgAAAAMyMDcAAAADNDU4AAAAAzQxMwAAAAM4MjAAAAADODg3AAAAAzk2OQAAAAIxOQAAAAM1MjYAAAADMzQwAAAA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AAAAAjgzAAAAAzQ0MQAAAAM4MzMAAAADOTg5AAAAAzkxNwAAAAM4MTMAAAADNjUyAAAAAjExAAAAAzE3MQAAAAM2MTAAAAADNjg4AAAAAzE0OQAAAAM3MzcAAAADNDQzAAAAAzQ3NQAAAAM3ODYAAAADMzc0AAAAAzk4NgAAAAIyNAAAAAM5MDMAAAADNjY2AAAAAzU5NwAAAAMzMjUAAAACNTMAAAADMTExAAAAAzI4MwAAAAM1NDAAAAACNDMAAAADNTE3AAAAAzQ2OQAAAAMyNjYAAAADNTE4AAAAAzk4OAAAAAIyNgAAAAMxMjAAAAADNzA2AAAAAzIyNgAAAAMxNDQAAAADNDE0AAAAAzUwMQAAAAMyMTEAAAADOTQ3AAAAAjU0AAAAAjY4AAAAAzE2OQAAAAMzMDMAAAADODEyAAAAAzU3MAAAAAM4MzEAAAACNjAAAAADNzkzAAAAAzkxNgAAAAM4MjEAAAADNDIyAAAAAzQ3NgAAAAM1NjUAAAADNjQ2AAAAAzQ2MQAAAAMxODQAAAADOTcxAAAAAzQxMAAAAAMyNDUAAAACNDAAAAADNDUzAAAAAzQxMgAAAAM5OTIAAAADNjg5AAAAAzgxMAAAAAMxMzEAAAADNTg3AAAAAzU2NgAAAAMxOTYAAAACODUAAAADNzIzAAAAAzI0MAAAAAM2MzQAAAADNDY0AAAAAzk1OAAAAAMxMDYAAAADMzM4AAAAAzU2MgAAAAM2MzcAAAADMTAwAAAAAzI2NAAAAAMxMTcAAAADNjU2AAAAAzIxNAAAAAMxODYAAAACNjk=
|
|
(1 row)
|
|
|
|
DROP TABLE base_texts;
|
|
-- low cardinality
|
|
CREATE TABLE base_texts AS SELECT row_number() OVER() as rn, item::text FROM
|
|
(SELECT i as item FROM generate_series(1, 10) i, generate_series(1, 100) j ORDER BY gen_rand_minstd()) sub;
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
605
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
DROP TABLE base_texts;
|
|
-- single element
|
|
CREATE TABLE base_texts AS SELECT row_number() OVER() as rn, item::text FROM (SELECT generate_series(1, 1) item) sub;
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
39
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
DROP TABLE base_texts;
|
|
-- high cardinality with toasted values
|
|
CREATE TABLE base_texts AS SELECT row_number() OVER() as rn, repeat(item::text, 100000) as item FROM
|
|
(select sub.item from (SELECT generate_series(1, 10) item) as sub ORDER BY gen_rand_minstd()) sub;
|
|
--make sure it's toasted
|
|
SELECT pg_total_relation_size(reltoastrelid)
|
|
FROM pg_class c
|
|
WHERE relname = 'base_texts';
|
|
pg_total_relation_size
|
|
------------------------
|
|
24576
|
|
(1 row)
|
|
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
1100084
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
DROP TABLE base_texts;
|
|
-- NULLs
|
|
CREATE TABLE base_texts AS SELECT row_number() OVER() as rn, NULLIF(i, 5)::TEXT item FROM generate_series(1, 10) i, generate_series(1, 100) j;
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
187
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
DROP TABLE base_texts;
|
|
CREATE TABLE base_texts AS SELECT row_number() OVER() as rn, NULLIF(i, 1)::TEXT item FROM generate_series(1, 10) i, generate_series(1, 100) j;
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
179
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
DROP TABLE base_texts;
|
|
CREATE TABLE base_texts AS SELECT row_number() OVER() as rn, NULLIF(i, 10)::TEXT item FROM generate_series(1, 10) i, generate_series(1, 100) j;
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
178
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
DROP TABLE base_texts;
|
|
CREATE TABLE base_texts AS SELECT row_number() OVER() as rn, NULLIF(NULLIF(NULLIF(NULLIF(i, 2), 4), 5), 8)::TEXT item FROM generate_series(1, 10) i, generate_series(1, 100) j;
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
189
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
DROP TABLE base_texts;
|
|
-----------------------
|
|
-- Array Compression --
|
|
-----------------------
|
|
SELECT
|
|
$$
|
|
select item from base_texts order by rn
|
|
$$ AS "QUERY"
|
|
\gset
|
|
\set TABLE_NAME base_texts
|
|
SELECT 'TEXT' as "TYPE" \gset
|
|
\set COMPRESSION_CMD _timescaledb_internal.compress_array(item)
|
|
\set DECOMPRESS_FORWARD_CMD _timescaledb_internal.decompress_forward(c::_timescaledb_internal.compressed_data, NULL::TEXT)
|
|
\set DECOMPRESS_REVERSE_CMD _timescaledb_internal.decompress_reverse(c::_timescaledb_internal.compressed_data, NULL::TEXT)
|
|
--basic test
|
|
CREATE TABLE base_texts AS SELECT row_number() OVER() as rn, item::text FROM
|
|
(select sub.item from (SELECT generate_series(1, 100) item) as sub ORDER BY gen_rand_minstd()) sub;
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
356
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
SELECT c from compressed;
|
|
c
|
|
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
AQBwZ19jYXRhbG9nAHRleHQAAAEAAABkAAAAAjU5AAAAAjg2AAAAAjE2AAAAAjM2AAAAAjk2AAAAAjM4AAAAAjI4AAAAAjEzAAAAAjczAAAAAjM3AAAAAjY5AAAAAjMxAAAAATkAAAACMTQAAAACNDQAAAABMQAAAAI3MQAAAAI2NgAAAAIxMAAAAAI4NQAAAAIyMwAAAAI3MAAAAAIyNQAAAAI4MAAAAAEzAAAAAjgzAAAAAjU2AAAAAjQ5AAAAAjUzAAAAAjI5AAAAAjk5AAAAATUAAAACNTIAAAACMjcAAAACNzkAAAACNDEAAAACNjUAAAACNTUAAAACNTAAAAACNjcAAAACNjEAAAACOTUAAAACNzcAAAACNzIAAAABNgAAAAI4MgAAAAIzNAAAAAI0NQAAAAI5NAAAAAI4NwAAAAI2MwAAAAI0NgAAAAIxOQAAAAI1MQAAAAI0NwAAAAEyAAAAATgAAAACOTIAAAACNTgAAAACNzUAAAACMTgAAAACOTMAAAACNDgAAAACNjAAAAACODQAAAACMTUAAAACMzAAAAACODgAAAACNzgAAAACNjQAAAACOTcAAAABNAAAAAI2MgAAAAI4MQAAAAI5OAAAAAI0MAAAAAI5MQAAAAE3AAAAAjI2AAAAAjQyAAAAAjg5AAAAAjEyAAAAAjkwAAAAAjE3AAAAAjc2AAAAAjM5AAAAAjMzAAAAAjMyAAAAAjIyAAAAAjY4AAAAAjQzAAAAAzEwMAAAAAIyMAAAAAIyNAAAAAI1NwAAAAIxMQAAAAIzNQAAAAI1NAAAAAI3NAAAAAIyMQ==
|
|
(1 row)
|
|
|
|
DROP TABLE base_texts;
|
|
-- single element
|
|
CREATE TABLE base_texts AS SELECT row_number() OVER() as rn, item::text FROM (SELECT generate_series(1, 1) item) sub;
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
39
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
DROP TABLE base_texts;
|
|
-- toasted values
|
|
CREATE TABLE base_texts AS SELECT row_number() OVER() as rn, repeat(item::text, 100000) as item FROM
|
|
(select sub.item from (SELECT generate_series(1, 10) item) as sub ORDER BY gen_rand_minstd()) sub;
|
|
--make sure it's toasted
|
|
SELECT pg_total_relation_size(reltoastrelid)
|
|
FROM pg_class c
|
|
WHERE relname = 'base_texts';
|
|
pg_total_relation_size
|
|
------------------------
|
|
24576
|
|
(1 row)
|
|
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
1100092
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
DROP TABLE base_texts;
|
|
-- NULLs
|
|
CREATE TABLE base_texts AS SELECT row_number() OVER() as rn, NULLIF(i, 5)::TEXT item FROM generate_series(1, 10) i;
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
80
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
DROP TABLE base_texts;
|
|
CREATE TABLE base_texts AS SELECT row_number() OVER() as rn, NULLIF(i, 1)::TEXT item FROM generate_series(1, 10) i;
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
80
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
DROP TABLE base_texts;
|
|
CREATE TABLE base_texts AS SELECT row_number() OVER() as rn, NULLIF(i, 10)::TEXT item FROM generate_series(1, 10) i;
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
79
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
DROP TABLE base_texts;
|
|
CREATE TABLE base_texts AS SELECT row_number() OVER() as rn, NULLIF(NULLIF(NULLIF(NULLIF(i, 2), 4), 5), 8)::TEXT item FROM generate_series(1, 10) i;
|
|
\ir include/compression_test.sql
|
|
-- This file and its contents are licensed under the Timescale License.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-TIMESCALE for a copy of the license.
|
|
\set ECHO errors
|
|
compressed size
|
|
-----------------
|
|
74
|
|
(1 row)
|
|
|
|
?column? | count
|
|
-------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed forward (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
--------------------------------------------------------------------------------+-------
|
|
Number of rows different between original and decompressed reversed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | count
|
|
----------------------------------------------------------------------------------------------------+-------
|
|
Number of rows different between original, decompressed, and decompressed deserializeed (expect 0) | 0
|
|
(1 row)
|
|
|
|
?column? | ?column?
|
|
-----------------------------------------------------------------------------------------------------+----------
|
|
Test that deserialization, decompression, recompression, and serialization results in the same text | t
|
|
(1 row)
|
|
|
|
DROP TABLE base_texts;
|