First, create a Stored Procedure that calls the query and sleeps every 10 seconds
use mydatabase DELIMITER $$ DROP PROCEDURE IF EXISTS `MyDataStatus` $$ CREATE PROCEDURE `MyDataStatus` () BEGIN SET @SecondsToPause = 10; SELECT COUNT(*) INTO @CurrentCount FROM domains; SET @Remaining = 456976 - @CurrentCount; WHILE @Remaining > 0 DO SELECT *,@CurrentCount as `count`,@CurrentCount as `remaining` FROM domains ORDER BY domain DESC LIMIT 0, 1; SELECT SLEEP(@SecondsToPause) INTO @SleepValue; SELECT COUNT(*) INTO @CurrentCount FROM domains; SET @Remaining = 456976 - @CurrentCount; END $$ DELIMITER ;
Now, call the Stored Procedure from DOS Command Line
set MYSQL_USER=root set MYSQL_PASS=password set MYSQL_MYDB=mydatabase set MYSQL_CONN=-u%MYSQL_USER% -p%MYSQL_PASS% -D%MYSQL_MYDB% mysql %MYSQL_CONN% -ANe"CALL MyDataStatus()"
or you could login to mysql
mysql %MYSQL_CONN%
then call the query at the MySQL prompt
mysql> CALL MyDataStatus();
Please notice I call the COUNT once and subtract it from 456976 to speed up the count a little.