• 首先生产环境不建议这样做,只是为了测试
  • 导致统计信息不准确的原因是什么呢?其实是MySQL 8.0为了提高information_schema的查询效率,将视图tables和statistics里面的统计信息缓存起来,缓存过期时间由参数information_schema_stats_expiry决定,默认为86400s;如果想获取最新的统计信息,可以通过如下两种方式:

    (1)analyze table进行表分析

    (2)设置information_schema_stats_expiry=0

  • 所以针对以上情况
     

    use mysql;
    SET GLOBAL information_schema_stats_expiry=0;
    SET @@GLOBAL.information_schema_stats_expiry=0;
    SET SESSION information_schema_stats_expiry=0;
    SET @@SESSION.information_schema_stats_expiry=0;

    use information_schema;
    -- select sum(table_rows) from tables where TABLE_SCHEMA = "limesurvey" order by table_rows asc;
    select table_name,table_rows from tables
    where TABLE_SCHEMA = 'limesurvey' and table_rows>0
    order by table_name ;

  • 首先生产环境不建议这样做,只是为了测试
  • 导致统计信息不准确的原因是什么呢?其实是MySQL 8.0为了提高information_schema的查询效率,将视图tables和statistics里面的统计信息缓存起来,缓存过期时间由参数information_schema_stats_expiry决定,默认为86400s;如果想获取最新的统计信息,可以通过如下两种方式:

    (1)analyze table进行表分析

    (2)设置information_schema_stats_expiry=0

  • 所以针对以上情况
     

    use mysql;
    SET GLOBAL information_schema_stats_expiry=0;
    SET @@GLOBAL.information_schema_stats_expiry=0;
    SET SESSION information_schema_stats_expiry=0;
    SET @@SESSION.information_schema_stats_expiry=0;

    use information_schema;
    -- select sum(table_rows) from tables where TABLE_SCHEMA = "limesurvey" order by table_rows asc;
    select table_name,table_rows from tables
    where TABLE_SCHEMA = 'limesurvey' and table_rows>0
    order by table_name ;

相关文章:

  • 2021-10-15
  • 2021-07-21
  • 2021-09-11
  • 2021-04-21
  • 2021-11-27
  • 2022-02-02
  • 2021-09-05
  • 2022-12-23
猜你喜欢
  • 2022-01-14
  • 2021-10-26
  • 2021-12-18
  • 2021-12-04
  • 2022-12-23
相关资源
相似解决方案