Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slow update on update query Postgresql

I run the an update query on a table of 36 millions of lines. This request takes 45 minutes to run. processed field is indexed, and the database is on a ssd.

UPDATE batch_item SET processed=true

do you have a clue why this is so long?

like image 360
d3cima Avatar asked Oct 23 '25 16:10

d3cima


1 Answers

I don't know how important your index is and whether 100% availability of it is crucial, but dropping the index, setting the value and adding the index back on at the end may save you time.

There's some useful information on bulk update operations here: https://www.codacy.com/blog/how-to-update-large-tables-in-postgresql/

like image 57
Sam Griffiths Avatar answered Oct 26 '25 11:10

Sam Griffiths



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!