| -- Tests for zstd compression. |
| -- Check that callbacks are registered |
| SELECT * FROM pg_compression WHERE compname = 'zstd'; |
| compname | compconstructor | compdestructor | compcompressor | compdecompressor | compvalidator | compowner |
| ----------+---------------------+--------------------+------------------+--------------------+-------------------+----------- |
| zstd | gp_zstd_constructor | gp_zstd_destructor | gp_zstd_compress | gp_zstd_decompress | gp_zstd_validator | 10 |
| (1 row) |
| |
| CREATE TABLE zstdtest (id int4, t text) WITH (appendonly=true, compresstype=zstd, orientation=column); |
| NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'id' as the Apache Cloudberry data distribution key for this table. |
| HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. |
| -- Check that the reloptions on the table shows compression type |
| SELECT reloptions FROM pg_class WHERE relname = 'zstdtest'; |
| reloptions |
| --------------------- |
| {compresstype=zstd} |
| (1 row) |
| |
| INSERT INTO zstdtest SELECT g, 'foo' || g FROM generate_series(1, 100000) g; |
| INSERT INTO zstdtest SELECT g, 'bar' || g FROM generate_series(1, 100000) g; |
| -- Check that we actually compressed data. With libzstd-1.4.4, the ratio is 2.66. With libzstd-1.3.7, the ratio is 2.62. With libzstd-1.3.3, the ration is 2.63. |
| SELECT get_ao_compression_ratio('zstdtest') IN (2.62, 2.63, 2.66); |
| ?column? |
| ---------- |
| t |
| (1 row) |
| |
| -- Check contents, at the beginning of the table and at the end. |
| SELECT * FROM zstdtest ORDER BY (id, t) LIMIT 5; |
| id | t |
| ----+------ |
| 1 | bar1 |
| 1 | foo1 |
| 2 | bar2 |
| 2 | foo2 |
| 3 | bar3 |
| (5 rows) |
| |
| SELECT * FROM zstdtest ORDER BY (id, t) DESC LIMIT 5; |
| id | t |
| --------+----------- |
| 100000 | foo100000 |
| 100000 | bar100000 |
| 99999 | foo99999 |
| 99999 | bar99999 |
| 99998 | foo99998 |
| (5 rows) |
| |
| -- Test different compression levels: |
| CREATE TABLE zstdtest_1 (id int4, t text) WITH (appendonly=true, compresstype=zstd, compresslevel=1); |
| NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'id' as the Apache Cloudberry data distribution key for this table. |
| HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. |
| CREATE TABLE zstdtest_10 (id int4, t text) WITH (appendonly=true, compresstype=zstd, compresslevel=10); |
| NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'id' as the Apache Cloudberry data distribution key for this table. |
| HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. |
| CREATE TABLE zstdtest_19 (id int4, t text) WITH (appendonly=true, compresstype=zstd, compresslevel=19); |
| NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'id' as the Apache Cloudberry data distribution key for this table. |
| HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. |
| INSERT INTO zstdtest_1 SELECT g, 'foo' || g FROM generate_series(1, 10000) g; |
| INSERT INTO zstdtest_1 SELECT g, 'bar' || g FROM generate_series(1, 10000) g; |
| SELECT * FROM zstdtest_1 ORDER BY (id, t) LIMIT 5; |
| id | t |
| ----+------ |
| 1 | bar1 |
| 1 | foo1 |
| 2 | bar2 |
| 2 | foo2 |
| 3 | bar3 |
| (5 rows) |
| |
| SELECT * FROM zstdtest_1 ORDER BY (id, t) DESC LIMIT 5; |
| id | t |
| -------+---------- |
| 10000 | foo10000 |
| 10000 | bar10000 |
| 9999 | foo9999 |
| 9999 | bar9999 |
| 9998 | foo9998 |
| (5 rows) |
| |
| INSERT INTO zstdtest_19 SELECT g, 'foo' || g FROM generate_series(1, 10000) g; |
| INSERT INTO zstdtest_19 SELECT g, 'bar' || g FROM generate_series(1, 10000) g; |
| SELECT * FROM zstdtest_19 ORDER BY (id, t) LIMIT 5; |
| id | t |
| ----+------ |
| 1 | bar1 |
| 1 | foo1 |
| 2 | bar2 |
| 2 | foo2 |
| 3 | bar3 |
| (5 rows) |
| |
| SELECT * FROM zstdtest_19 ORDER BY (id, t) DESC LIMIT 5; |
| id | t |
| -------+---------- |
| 10000 | foo10000 |
| 10000 | bar10000 |
| 9999 | foo9999 |
| 9999 | bar9999 |
| 9998 | foo9998 |
| (5 rows) |
| |
| -- Test the bounds of compresslevel. None of these are allowed. |
| CREATE TABLE zstdtest_invalid (id int4) WITH (appendonly=true, compresstype=zstd, compresslevel=-1); |
| NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'id' as the Apache Cloudberry data distribution key for this table. |
| HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. |
| ERROR: value -1 out of bounds for option "compresslevel" |
| DETAIL: Valid values are between "0" and "19". |
| CREATE TABLE zstdtest_invalid (id int4) WITH (appendonly=true, compresstype=zstd, compresslevel=0); |
| NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'id' as the Apache Cloudberry data distribution key for this table. |
| HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. |
| ERROR: compresstype "zstd" can't be used with compresslevel 0 |
| CREATE TABLE zstdtest_invalid (id int4) WITH (appendonly=true, compresstype=zstd, compresslevel=20); |
| NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'id' as the Apache Cloudberry data distribution key for this table. |
| HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. |
| ERROR: value 20 out of bounds for option "compresslevel" |
| DETAIL: Valid values are between "0" and "19". |
| -- CREATE TABLE for heap table with compresstype=zstd should fail |
| CREATE TABLE zstdtest_heap (id int4, t text) WITH (compresstype=zstd); |
| NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'id' as the Apache Cloudberry data distribution key for this table. |
| HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. |
| ERROR: unrecognized parameter "compresstype" |