Hi Hackers, I think it would be a waste to retain xmin and cmin for frozen tuples because their values represent only 'visible for all transactions'. Additionally, most tuples in database can be frozen potentially.
I wrote a makeshift patch to compress xmin and cmin (8bytes) to 1-bit flag, using tuple overlaping. Is this idea worth trying? Also, it will be useful to combine it and more aggressive freeze vacuum, for example, a freezer integrated with bgwriter. (The following is test of the attached patch) * Test query 1. create table test (a int); 2. insert into test select * from generate_series(1, 100000); 3. update test set a = a where a % 100 = 0; # to force defrag 4. select * from pgstattuple('test'); 5. vacuum freeze test; 6. select * from pgstattuple('test'); * Results of pgstattuple -[ before vacuum ]-+-------- table_len | 3645440 tuple_count | 100000 tuple_len | 3200000 tuple_percent | 87.78 dead_tuple_count | 1000 dead_tuple_len | 32000 dead_tuple_percent | 0.88 free_space | 536 free_percent | 0.01 -[ 8.1beta1 orig ]-+-------- table_len | 3645440 tuple_count | 100000 tuple_len | 3200000 tuple_percent | 87.78 dead_tuple_count | 0 dead_tuple_len | 0 dead_tuple_percent | 0 free_space | 30772 <-- about 32byte * 1000 (dead tuples) free_percent | 0.84 -[ patched ]-------+-------- table_len | 3645440 tuple_count | 100000 tuple_len | 3200000 tuple_percent | 87.78 dead_tuple_count | 0 dead_tuple_len | 0 dead_tuple_percent | 0 free_space | 823628 <-- + 8byte * 100000 (whole tuples) free_percent | 22.59 --- ITAGAKI Takahiro NTT Cyber Space Laboratories
xmincut.patch
Description: Binary data
---------------------------(end of broadcast)--------------------------- TIP 6: explain analyze is your friend