Skip to content

Commit

Permalink
Test interaction with both toast compression types in columnar_insert
Browse files Browse the repository at this point in the history
  • Loading branch information
Karina Litskevich committed Aug 14, 2024
1 parent 9e1852e commit 6872687
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 24 deletions.
49 changes: 35 additions & 14 deletions src/test/regress/expected/columnar_insert.out
Original file line number Diff line number Diff line change
Expand Up @@ -122,33 +122,54 @@ DROP TABLE test_logical_replication;
-- test toast interactions
--
-- row table with data in different storage formats
CREATE TABLE test_toast_row(plain TEXT, main TEXT, external TEXT, extended TEXT);
CREATE TABLE test_toast_row(
plain TEXT,
main_pglz TEXT COMPRESSION pglz,
main_lz4 TEXT COMPRESSION lz4,
external TEXT,
extended_pglz TEXT COMPRESSION pglz,
extended_lz4 TEXT COMPRESSION lz4
);
ALTER TABLE test_toast_row ALTER COLUMN plain SET STORAGE plain; -- inline, uncompressed
ALTER TABLE test_toast_row ALTER COLUMN main SET STORAGE main; -- inline, compressed
ALTER TABLE test_toast_row ALTER COLUMN main_pglz SET STORAGE main; -- inline, compressed using pglz
ALTER TABLE test_toast_row ALTER COLUMN main_lz4 SET STORAGE main; -- inline, compressed using lz4
ALTER TABLE test_toast_row ALTER COLUMN external SET STORAGE external; -- out-of-line, uncompressed
ALTER TABLE test_toast_row ALTER COLUMN extended SET STORAGE extended; -- out-of-line, compressed
ALTER TABLE test_toast_row ALTER COLUMN extended_pglz SET STORAGE extended; -- out-of-line, compressed using pglz
ALTER TABLE test_toast_row ALTER COLUMN extended_lz4 SET STORAGE extended; -- out-of-line, compressed using lz4
INSERT INTO test_toast_row VALUES(
repeat('w', 5000), repeat('x', 5000), repeat('y', 5000), repeat('z', 5000));
repeat('u', 5000), repeat('v', 5000), repeat('w', 5000),
repeat('x', 5000), repeat('y', 5000), repeat('z', 5000)
);
SELECT
pg_column_size(plain), pg_column_size(main),
pg_column_size(external), pg_column_size(extended)
pg_column_size(plain) AS plain,
pg_column_size(main_pglz) as main_pglz,
pg_column_size(main_lz4) as main_lz4,
pg_column_size(external) as external,
pg_column_size(extended_pglz) as extended_pglz,
pg_column_size(extended_lz4) as extended_lz4
FROM test_toast_row;
pg_column_size | pg_column_size | pg_column_size | pg_column_size
plain | main_pglz | main_lz4 | external | extended_pglz | extended_lz4
---------------------------------------------------------------------
5004 | 69 | 5000 | 65
5004 | 69 | 38 | 5000 | 65 | 34
(1 row)

CREATE TABLE test_toast_columnar(plain TEXT, main TEXT, external TEXT, extended TEXT)
CREATE TABLE test_toast_columnar(plain TEXT, main_pglz TEXT, main_lz4 TEXT,
external TEXT, extended_pglz TEXT, extended_lz4 TEXT)
USING columnar;
INSERT INTO test_toast_columnar SELECT plain, main, external, extended
INSERT INTO test_toast_columnar
SELECT plain, main_pglz, main_lz4, external, extended_pglz, extended_lz4
FROM test_toast_row;
SELECT
pg_column_size(plain), pg_column_size(main),
pg_column_size(external), pg_column_size(extended)
pg_column_size(plain) AS plain,
pg_column_size(main_pglz) as main_pglz,
pg_column_size(main_lz4) as main_lz4,
pg_column_size(external) as external,
pg_column_size(extended_pglz) as extended_pglz,
pg_column_size(extended_lz4) as extended_lz4
FROM test_toast_columnar;
pg_column_size | pg_column_size | pg_column_size | pg_column_size
plain | main_pglz | main_lz4 | external | extended_pglz | extended_lz4
---------------------------------------------------------------------
5004 | 5004 | 5004 | 5004
5004 | 5004 | 5004 | 5004 | 5004 | 5004
(1 row)

select
Expand Down
43 changes: 33 additions & 10 deletions src/test/regress/sql/columnar_insert.sql
Original file line number Diff line number Diff line change
Expand Up @@ -83,27 +83,50 @@ DROP TABLE test_logical_replication;
--

-- row table with data in different storage formats
CREATE TABLE test_toast_row(plain TEXT, main TEXT, external TEXT, extended TEXT);
CREATE TABLE test_toast_row(
plain TEXT,
main_pglz TEXT COMPRESSION pglz,
main_lz4 TEXT COMPRESSION lz4,
external TEXT,
extended_pglz TEXT COMPRESSION pglz,
extended_lz4 TEXT COMPRESSION lz4
);
ALTER TABLE test_toast_row ALTER COLUMN plain SET STORAGE plain; -- inline, uncompressed
ALTER TABLE test_toast_row ALTER COLUMN main SET STORAGE main; -- inline, compressed
ALTER TABLE test_toast_row ALTER COLUMN main_pglz SET STORAGE main; -- inline, compressed using pglz
ALTER TABLE test_toast_row ALTER COLUMN main_lz4 SET STORAGE main; -- inline, compressed using lz4
ALTER TABLE test_toast_row ALTER COLUMN external SET STORAGE external; -- out-of-line, uncompressed
ALTER TABLE test_toast_row ALTER COLUMN extended SET STORAGE extended; -- out-of-line, compressed
ALTER TABLE test_toast_row ALTER COLUMN extended_pglz SET STORAGE extended; -- out-of-line, compressed using pglz
ALTER TABLE test_toast_row ALTER COLUMN extended_lz4 SET STORAGE extended; -- out-of-line, compressed using lz4

INSERT INTO test_toast_row VALUES(
repeat('w', 5000), repeat('x', 5000), repeat('y', 5000), repeat('z', 5000));
repeat('u', 5000), repeat('v', 5000), repeat('w', 5000),
repeat('x', 5000), repeat('y', 5000), repeat('z', 5000)
);

SELECT
pg_column_size(plain), pg_column_size(main),
pg_column_size(external), pg_column_size(extended)
pg_column_size(plain) AS plain,
pg_column_size(main_pglz) as main_pglz,
pg_column_size(main_lz4) as main_lz4,
pg_column_size(external) as external,
pg_column_size(extended_pglz) as extended_pglz,
pg_column_size(extended_lz4) as extended_lz4
FROM test_toast_row;

CREATE TABLE test_toast_columnar(plain TEXT, main TEXT, external TEXT, extended TEXT)
CREATE TABLE test_toast_columnar(plain TEXT, main_pglz TEXT, main_lz4 TEXT,
external TEXT, extended_pglz TEXT, extended_lz4 TEXT)
USING columnar;
INSERT INTO test_toast_columnar SELECT plain, main, external, extended

INSERT INTO test_toast_columnar
SELECT plain, main_pglz, main_lz4, external, extended_pglz, extended_lz4
FROM test_toast_row;

SELECT
pg_column_size(plain), pg_column_size(main),
pg_column_size(external), pg_column_size(extended)
pg_column_size(plain) AS plain,
pg_column_size(main_pglz) as main_pglz,
pg_column_size(main_lz4) as main_lz4,
pg_column_size(external) as external,
pg_column_size(extended_pglz) as extended_pglz,
pg_column_size(extended_lz4) as extended_lz4
FROM test_toast_columnar;

select
Expand Down

0 comments on commit 6872687

Please sign in to comment.