Skip to content

FILLFACTOR

CREATE TABLE test_table(
ID Int PRIMARY KEY,
Data Text
) WITH (FILLFACTOR = 70);
INSERT INTO test_table(ID, Data) VALUES
(1, 'Data 1'),
(2, 'Data 2'),
(3, 'Data 3'),
(4, 'Data 4'),
(5, 'Data 5');
SHOW (pg_total_relation_size('test_table'));
pg_total_relation_size
-----------------------
65536

In the above example, a table test_table is created with two columns ID and Data. By specifying WITH (FILLFACTOR = 70), the table is set to leave 30% of each block empty for future updates and inserts under the same database block, resulting in less page splits. Five rows of data are inserted into the table. The final command SHOW (pg_total_relation_size('test_table')) shows the total disk space occupied by the test_table table in bytes.