First set up the initial variables (those to compare against - this is time 0)
PaulBo@test_db:SELECT @time:=UNIX_TIMESTAMP(), @apples:=(SELECT COUNT(*) FROM apples), @oranges:=(SELECT COUNT(*) FROM oranges);
Then, let some time pass and poll the tables for changes:
PaulBo@test_db:SELECT UNIX_TIMESTAMP() - @time as elapsed_time, (SELECT COUNT(*) FROM apples) - @apples as d_apples, (SELECT COUNT(*) FROM oranges) - @oranges as d_oranges;
+--------------+----------+-----------+
| elapsed_time | d_apples | d_oranges |
+--------------+----------+-----------+
| 435 | 230 | 12887 |
+--------------+----------+-----------+
1 row in 1 set (0.00 sec)
No comments:
Post a Comment