Sample Header Ad - 728x90

PostgreSql 14 LZ4 not showing pg_column_compression. Not working with COPY import command

0 votes
1 answer
944 views
I have setup two test systems for primary/stanbdy replication. On the bigger VM with more CPU power I did default_toast_compression = lz4 and wal_compression=on. When i created tables on that VM I could see the compression method in the pg_column_compression. Now I added a second VM with only 2 vCPUs that plays the role of primary in replication wal_level=replica and also default LZ4 but when i create tables it does not show up as compressed. Not even if I use pglz or lz4. test01=# \d+ sales_record Table "public.sales_record" Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description ----------------+-------------------+-----------+----------+---------+----------+-------------+--------------+------------- region | character varying | | | | extended | lz4 | | country | character varying | | | | extended | lz4 | | item_type | character varying | | | | extended | lz4 | | sales_channel | character varying | | | | extended | lz4 | | order_priority | character(1) | | | | extended | lz4 | | order_date | date | | | | plain | | | order_id | integer | | | | plain | | | I can see that the table has LZ4 but when I issue SELECT pg_column_compression(country) from public.sales_record; I see only NULL values. test01=# SELECT pg_column_compression(region) from public.sales_record limit 10; pg_column_compression ----------------------- (10 rows) What have i missed here? I just wanted to test out LZ4. Is it because I only used COPY to import CSV file ? I inserted data into sales_record using: COPY sales_record FROM '/var/lib/pgsql/14/import/50000SalesR.csv' CSV HEADER; Additional test when I do simple INSERT on another table I see that it is being compressed. CREATE TABLE tbl (id int, col1 text COMPRESSION pglz, col2 text COMPRESSION lz4, col3 text); INSERT INTO tbl VALUES (1, repeat('abc',1000), repeat('abc',1000),repeat('abc',1000)); Then I double check: test01=# SELECT pg_column_compression(col3) from public.tbl limit 5; pg_column_compression ----------------------- lz4 lz4 lz4 lz4 lz4 (5 rows) test01=# SELECT pg_column_compression(col1) from public.tbl limit 5; pg_column_compression ----------------------- pglz pglz pglz pglz pglz (5 rows) So it seems I need to use some switches if COPY command can use compression during import of CSV data ?
Asked by ultimo_frogman (31 rep)
Nov 5, 2022, 06:59 AM
Last activity: Jul 14, 2025, 02:04 AM