简体   繁体   English

Amazon AWS RDS MySQL慢查询日志

[英]Amazon AWS RDS MySQL slow query log

I have Mysql DB on AWS RDS instance, and I have a slow query log with log_queries_not_using_indexes = YES 我在AWS RDS实例上具有Mysql DB,并且查询日志log_queries_not_using_indexes = YES慢

And it is working but almost every 5 seconds, this is what I am seeing in log: 它正在工作,但是几乎每5秒一次,这就是我在日志中看到的内容:

SELECT value FROM mysql.rds_heartbeat2;
# Time: 150804 21:00:25
# User@Host: rdsadmin[rdsadmin] @ localhost [127.0.0.1] Id: 1
# Query_time: 0.000154 Lock_time: 0.000058 Rows_sent: 1 Rows_examined: 1
SET timestamp=1438722025;
SELECT NAME, VALUE FROM mysql.rds_configuration;
# Time: 150804 21:00:30
# User@Host: rdsadmin[rdsadmin] @ localhost [127.0.0.1] Id: 1
# Query_time: 0.000233 Lock_time: 0.000113 Rows_sent: 1 Rows_examined: 1
SET timestamp=1438722030;
SELECT count(*) from information_schema.TABLES WHERE TABLE_SCHEMA = 'mysql' AND TABLE_NAME = 'rds_heartbeat2';
# User@Host: rdsadmin[rdsadmin] @ localhost [127.0.0.1] Id: 1
# Query_time: 0.000116 Lock_time: 0.000039 Rows_sent: 1 Rows_examined: 1
SET timestamp=1438722030;
SELECT value FROM mysql.rds_heartbeat2;
# Time: 150804 21:00:45
# User@Host: rdsadmin[rdsadmin] @ localhost [127.0.0.1] Id: 1
# Query_time: 0.000238 Lock_time: 0.000116 Rows_sent: 1 Rows_examined: 1
SET timestamp=1438722045;
SELECT count(*) from information_schema.TABLES WHERE TABLE_SCHEMA = 'mysql' AND TABLE_NAME = 'rds_heartbeat2';
# User@Host: rdsadmin[rdsadmin] @ localhost [127.0.0.1] Id: 1
# Query_time: 0.000112 Lock_time: 0.000036 Rows_sent: 1 Rows_examined: 1
SET timestamp=1438722045;
SELECT value FROM mysql.rds_heartbeat2;
# Time: 150804 21:01:00

What is this? 这是什么?

I have maybe one or two my queries which I need to optimize and rest of log file is this. 我可能需要优化一两个查询,其余的日志文件就是这个。

How is this related to my databases? 这与我的数据库有什么关系? Those queries are not mine. 这些查询不是我的。 I believe this is something what AWS do but I don't know why and how it affects the performance. 我相信这是AWS所做的事情,但我不知道为什么以及如何影响性能。

Those database are part of the Mysql server. 这些数据库是Mysql服务器的一部分。 Although I suspect that rds_heartbeat2 and rds_configuration are specific to the AWS RDS version of mysql. 尽管我怀疑rds_heartbeat2rds_configuration特定于MySQL的AWS RDS版本。 You can read more about heartbeat . 您可以阅读有关心跳的更多信息。

From dev.mysql : dev.mysql

INFORMATION_SCHEMA is a database within each MySQL instance, the place that stores information about all the other databases that the MySQL server maintains. INFORMATION_SCHEMA是每个MySQL实例中的一个数据库,该位置存储有关MySQL服务器维护的所有其他数据库的信息。 The INFORMATION_SCHEMA database contains several read-only tables. INFORMATION_SCHEMA数据库包含几个只读表。 They are actually views, not base tables, so there are no files associated with them, and you cannot set triggers on them. 它们实际上是视图,而不是基表,因此没有与它们关联的文件,并且您不能在它们上设置触发器。 Also, there is no database directory with that name. 另外,没有使用该名称的数据库目录。

You can run this command to see which databases have MyISAM Tables: 您可以运行以下命令来查看哪些数据库具有MyISAM表:

select distinct(table_schema) FROM information_schema.tables where engine = 'MyISAM';

From dev.mysql . 来自dev.mysql

The mysql system database includes several grant tables that contain information about user accounts and the privileges held by them. mysql系统数据库包括几个授权表,这些表包含有关用户帐户及其所拥有特权的信息。

You can run this command to see a list of users and host: 您可以运行以下命令来查看用户和主机的列表:

select user, host from mysql.user;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM