Home > Mobile >  Batch UPDATES sleep(10)
Batch UPDATES sleep(10)

Time:02-22

Im writing an update statement that affects a number of rows in one table on my database.

To accomplish this, I want to break that up into manageable chunks.

Initially, I thought using CONCAT would help, SELECT CONCAT("UPDATE table SET foo=bar WHERE ID=", id, ";") FROM

I want to batch all these up, otherwise there will potentially cause replication lag. Preferably with do sleep(10); in between each batch

How can I accomplish this? How can I do sleep (10) between queries?

My queries right now look like this:

UPDATE table SET created_at = NOW() WHERE id IN (?,?,?...);

CodePudding user response:

How can I do sleep (10) between queries?

Simply add SELECT SLEEP(10); between your queries.

https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_sleep

CodePudding user response:

Resolved

Adding DO SLEEP(10) before each UPDATE is what I needed

  • Related