Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(suggestion) Checking Table Changes by using UPDATE_TIME in table status #77

Open
EvanGeminika opened this issue Nov 14, 2016 · 2 comments

Comments

@EvanGeminika
Copy link

I wonder whether it's possible to check table changes by using UPDATE_TIME in table status.
For example, below query result will give UPDATE_TIME

show table status where name='players';

The module can run above query every minute to check whether any changes in player table in the last 1 minute.
This way, this module can still be reactive without binary log.

@numtel
Copy link
Owner

numtel commented Dec 15, 2016

That is quite interesting. I didn't know about SHOW TABLE STATUS.

@Geminika Is there a way to select rows that have been updating since a specified time?

@EvanGeminika
Copy link
Author

EvanGeminika commented Dec 15, 2016

@numtel, currently it works fine with MyISAM engine, but there's still some problem with InnoDB.
That's why by default the update_time is null for InnoDB.
They said it will work for InnoDB in MySQL 5.7.2, based on this link https://bugs.mysql.com/bug.php?id=14374

SHOW TABLE STATUS, is basically gives the same result as below query:

SELECT * FROM information_schema.tables WHERE table_schema = DATABASE();

We can use below create table command, if we want to test it with MyISAM engine.
CREATE TABLE players
(
id int PRIMARY KEY NOT NULL,
name varchar(45),
score int DEFAULT 0 NOT NULL
) engine MyISAM;

We can use below sample query if we want to get the update_time for players table.

select table_name, update_time
from information_schema.tables
where table_schema = DATABASE()
and table_name="players";

The update_time will change when any insert, update, or delete happen for that table.

To check whether any changes in the table since the last 5 minutes we can use below query:

select table_name, update_time
from information_schema.tables
where table_schema = DATABASE()
and table_name="players"
and update_time > (now() - interval 5 minute);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants