Slow query on information_schema.tables

前端 未结 2 1679
醉酒成梦
醉酒成梦 2020-12-18 01:18

I run a set of self-developed applications on a typical shared hosting service offering. I moved from a static configured table list of allowed tables to one based on a lis

相关标签:
2条回答
  • 2020-12-18 02:00

    For those who may want a hack with a minor drawback: http://www.mysqlperformanceblog.com/2011/12/23/solving-information_schema-slowness/

    What it does is it disable some stats that get updated if you query the schema, more information here: http://dev.mysql.com/doc/refman/5.1/en/innodb-parameters.html#sysvar_innodb_stats_on_metadata

    And to make things easier for lazy bums who don't want to read, you only need to make a change to a setting:

    innodb_stats_on_metadata=0
    

    You can do this in the config file or dynamically:

    mysql> set global innodb_stats_on_metadata=0;
    
    0 讨论(0)
  • 2020-12-18 02:05

    The information schema is not optimized, there are no indexes, just tables with metadata, and usually, when you run SELECT from the schema, it opens and reads files.

    Have a look at this article - Optimizing INFORMATION_SCHEMA Queries; in some cases it will help you.

    0 讨论(0)
提交回复
热议问题