Basically I need to run this on a table with 40 million rows, updating every row at once will crash, so I want to batch the query so that if it crash, it can re-run the quer
Fastest way is to :
1) Create a temp table and insert all the values from old to temp table using the create(select having condition) statement.
2) Copy the constraints and refresh the indexes.
3) Drop the old table.
4) Rename temp table to original name.
Complete discussion is available on this link