mysql.slow_log表默认引擎是CSV,CSV引擎没有索引; 当数据量很大时,该引擎性能非常慢;
如何将Amamon RDS mysql.slow_log表的引擎更改为innodb
最佳答案
简短的回答是你不能这样做。长答案是 MySQL 文档 log destinations说:
The log tables can be altered to use the MyISAM storage engine. You cannot use ALTER TABLE to alter a log table that is in use. The log must be disabled first. No engines other than CSV or MyISAM are legal for the log tables.
To disable logging so that you can alter (or drop) a log table, you can use the following strategy. The example uses the general query log; the procedure for the slow query log is similar but uses the slow_log table and slow_query_log system variable.
SET @old_log_state = @@global.general_log; SET GLOBAL general_log = 'OFF'; ALTER TABLE mysql.general_log ENGINE = MyISAM; SET GLOBAL general_log = @old_log_state;
当然,您可以尝试将表引擎更改为innodb,看看亚马逊版本是否解除了限制,但只能在测试环境中进行。
关于mysql - 如何将 Amazon RDS mysql.slow_log 表引擎更改为 innodb,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40585021/