What should be the fill-factor for a table where only fixed-width columns will be updated?

dba.stackexchange https://dba.stackexchange.com/questions/147048

  •  03-10-2020
  •  | 
  •  

Question

We have a table where we are planning to update timestamp fields only.

In the first import these columns will be nulls then we will update them as the computation finished on these rows.

The question is; should we set a fill-factor lower than 100 for this table or PostgreSQL will allocate a fixed size for these columns so lowering the fill-factor makes no sense?

Was it helpful?

Solution

PostgreSQL never does in-place updates of the data, so it doesn't matter whether the records are fixed width or not when deciding whether the fillfactor should be 100. It always has to find new space for the new data, even if the new data is the same width or narrow than the old data. And if you set the fillfactor to 100 that new space will usually have to be in a different block.

Once you decide you do want to lower the fillfactor, then the fact that the width of the tuples will increase as you fill them out does mean you should lower it by more than you otherwise would.

OTHER TIPS

Postgres doesn't store nulls directly in the field but rather keeps a bitmap of null values. So using 100 will be problematic.

What you can do is use some default value such as 1/1/1970 just to allocate the spot for the field.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top