one table of size 926gb and I need to update one column to null where all records are less than Jan 2021. I tried the obvious way but it's taking forever. Any suggestion?
How many rows are in your table?
Percona tools has something for batch updates if you want but it is not a big deal to write something simple on your own. Honestly saying, 10m rows is almost nothing
Write a cursor to select the rows you need to update. Ensure the query filter is covered by an effective index, if not, you have to create one. Run the cursor and in the body of it update the current row with the desired values. Keep counter of processed rows and commit the current transaction every N rows, where N is something like 100 or 1000,or maybe more. Also ensue all your process can be killed and restarted at any time. Add indication of overall process status by selecting periodically the number of rows processed so far. All this code is practical to organize in the form of stored procedure.
Обсуждают сегодня