Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test interaction with both toast compression types in columnar_insert #7670

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading