MySql查询数据表最后更新时间,解决information_schema记录延迟

MySql系统表可查询数据表的最后更新时间

select update_time from information_schema.`TABLES` where table_schema = 'cms' and table_name = 'user'


但InnoDB引擎下更新记录会有延迟。
可以通过设置状态有效期来解决,information_schema.`TABLES`中记录的update_time超过有效期才会更新,有效期设置为零则实时更新。

set session information_schema_stats_expiry=0;
set global information_schema_stats_expiry=0;

猜你喜欢

转载自blog.csdn.net/secretdaixin/article/details/128343842