Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Putting index on a column that gets updated frequently in postgres

In a postgres db, I have a table with an UpdatedAtDate column that I put an index on. This column also gets updated frequently. Will the index be updated every time that column is updated and could this lead to performance issues? Thanks.

like image 772
blankface Avatar asked Nov 16 '25 05:11

blankface


1 Answers

Yes, the index has to be updated whenever you update the column.

What is worse, that index will prevent HOT updates, which greatly reduce the need for autovacuum runs to get rid of old, outdated row versions.

So if you can, drop that index and set the fillfactor for the table to less than 100.

like image 77
Laurenz Albe Avatar answered Nov 17 '25 22:11

Laurenz Albe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!