BUG #16803: create a table only one text/varchar column, storage options toast_tuple_target doesn't work

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: mailtch(at)163(dot)com
Subject: BUG #16803: create a table only one text/varchar column, storage options toast_tuple_target doesn't work
Date: 2021-01-04 14:53:12
Message-ID: 16803-0acffe06339b12be@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 16803
Logged by: osdba
Email address: mailtch(at)163(dot)com
PostgreSQL version: 11.10
Operating system: CentOS7.6
Description:

create a table only one text/varchar colume, storage options
toast_tuple_target doesn't work, see:

[pg03(at)pgtrain pgdata]$ psql
psql (11.10)
Type "help" for help.

postgres=# create table test01(id int, t text);
CREATE TABLE
postgres=# alter table test01 set (toast_tuple_target=1024);
ALTER TABLE
postgres=# insert into test01 select seq, repeat('a', 1800) from
generate_series(1, 1000) as seq;
INSERT 0 1000
postgres=# select pg_total_relation_size('test01');
pg_total_relation_size
------------------------
2080768
(1 row)

postgres=# truncate table test01;
TRUNCATE TABLE
postgres=# insert into test01 select seq, repeat('a', 2800) from
generate_series(1, 1000) as seq;
INSERT 0 1000
postgres=# select pg_total_relation_size('test01');
pg_total_relation_size
------------------------
114688
(1 row)

because I set toast_tuple_target to 1024,so trigger toast compress when
insert data that length is 1800 or 2800, but only trigger toast compress
when data length is 2800.

when I create table have more than one text column, then storage options
toast_tuple_target can be work correctly:

postgres=# create table test01(id int, t1 text, t2 text);
CREATE TABLE
postgres=# alter table test01 set (toast_tuple_target=1024);
ALTER TABLE
postgres=# insert into test01 select seq, repeat('a', 1800), repeat('b',
1800) from generate_series(1, 1000) as seq;
INSERT 0 1000
postgres=# select pg_total_relation_size('test01');
pg_total_relation_size
------------------------
139264
(1 row)

postgres=# truncate table test01;
TRUNCATE TABLE
postgres=# insert into test01 select seq, repeat('a', 2800), repeat('b',
2800) from generate_series(1, 1000) as seq;
INSERT 0 1000
postgres=# select pg_total_relation_size('test01');
pg_total_relation_size
------------------------
163840
(1 row)

you can see, when table have two text column, then storage options
toast_tuple_target can be work correctly.

this is a bug?

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2021-01-04 17:48:20 BUG #16804: substring() function returns "negative substring length" error when using a large length argument
Previous Message Michael Paquier 2021-01-04 10:55:11 Re: how to prepare a create table statement