MySQL trigger/procedure execution delay

Since MySQL 5.0.12, you can do this:

SELECT SLEEP(<seconds>);

The seconds parameter can be in a fraction of a second like .5.


DO SLEEP(<seconds>);

is better. There is no reason to just run SELECT statements inside triggers without needing the result set. If you really want to do this you need to do it like here:

SET @nothing = (SELECT SLEEP(<seconds>));

But I recommend to use DO. And don't forget that a trigger is just a single statement per default. If you have more then 1 statement in your trigger you need to use BEGIN/END:

BEGIN
    DO SLEEP(<seconds>);
    UPDATE ...;
END