3 ms·
> Gradually backfill the default value Might I add a little warning from experience. The "gradually" part is important to get right, since in postgres updates
by gldalmaso 9y ago
> Gradually backfill the default value
Might I add a little warning from experience.
The "gradually" part is important to get right, since in postgres updates actually create new tuples and leave dead tuples behind, if you update too much at once two things might happen: you increase disk usage fast (worth considering how much room you have to work and adjust before if needed) and increase the amount of dead tuples fast.
I have experienced that having too much dead tuples on a table might impact the query planner and it may stop using some index completely before autovacuum does its job. Depending on the circumstance this may severely impact performance if an important query suddenly starts Seq Scanning a huge table.
This blog post has great practical details to consider before running such updates: https://www.citusdata.com/blog/2016/11/04/autovacuum-not-the-enemy/ https://www.citusdata.com/blog/2016/11/04/autovacuum-not-the...
In particular at the time we had to adjust the "autovacuum_vacuum_scale_factor" for the table in order for the autovacuum process to kick in much sooner. Also there is a valuable query there to inspect how much dead tuples you have.
- jimktrains2 9y agoActually, if you don't change any keys I believe it can update in place under certain circumstances. I'll have to find a link.
- ddorian43 9y agoYou mean heap-only-tuples: https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/access/heap/README.HOT;hb=HEAD https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f...
- jimktrains2 9y agoYes, I was just about to post https://github.com/postgres/postgres/blob/master/src/backend/access/heap/README.HOT https://github.com/postgres/postgres/blob/master/src/backend... I misremembered it a little in my original post. (I'm not able to open your link for some reason :-\)
- deleted 9y ago[deleted]