这期内容当中小编将会给大家带来有关mysql的常用系统表和视图有哪些,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。
一.information_schema下常用表
1.SCHEMATA
实例下所有数据库的信息
*************************** 1. row ***************************
CATALOG_NAME: def
SCHEMA_NAME: information_schema
DEFAULT_CHARACTER_SET_NAME: utf8
DEFAULT_COLLATION_NAME: utf8_general_ci
SQL_PATH: NULL
2.TABLES
提供了表和视图的详细信息
*************************** 298. row ***************************
TABLE_CATALOG: def
TABLE_SCHEMA: wwj2
TABLE_NAME: t1
TABLE_TYPE: BASE TABLE
ENGINE: InnoDB
VERSION: 10
ROW_FORMAT: Dynamic
TABLE_ROWS: 3
AVG_ROW_LENGTH: 5461
DATA_LENGTH: 16384
MAX_DATA_LENGTH: 0
INDEX_LENGTH: 0
DATA_FREE: 0
AUTO_INCREMENT: 4
CREATE_TIME: 2018-04-17 10:44:04
UPDATE_TIME: NULL
CHECK_TIME: NULL
TABLE_COLLATION: utf8mb4_unicode_ci
CHECKSUM: NULL
CREATE_OPTIONS:
TABLE_COMMENT:
3.COLUMNS
详细的表列信息
*************************** 1. row ***************************
TABLE_CATALOG: def
TABLE_SCHEMA: wwj
TABLE_NAME: t3
COLUMN_NAME: idt3
ORDINAL_POSITION: 1
COLUMN_DEFAULT: NULL
IS_NULLABLE: NO
DATA_TYPE: int
CHARACTER_MAXIMUM_LENGTH: NULL
CHARACTER_OCTET_LENGTH: NULL
NUMERIC_PRECISION: 10
NUMERIC_SCALE: 0
DATETIME_PRECISION: NULL
CHARACTER_SET_NAME: NULL
COLLATION_NAME: NULL
COLUMN_TYPE: int(11)
COLUMN_KEY: PRI
EXTRA:
PRIVILEGES: select,insert,update,references
COLUMN_COMMENT:
GENERATION_EXPRESSION:
4.STATISTICS
表的索引信息
*************************** 1. row ***************************
TABLE_CATALOG: def
TABLE_SCHEMA: wwj
TABLE_NAME: t3
NON_UNIQUE: 0
INDEX_SCHEMA: wwj
INDEX_NAME: PRIMARY
SEQ_IN_INDEX: 1
COLUMN_NAME: idt3
COLLATION: A
CARDINALITY: 8
SUB_PART: NULL
PACKED: NULL
NULLABLE:
INDEX_TYPE: BTREE
COMMENT:
INDEX_COMMENT:
*************************** 2. row ***************************
TABLE_CATALOG: def
TABLE_SCHEMA: wwj
TABLE_NAME: t3
NON_UNIQUE: 1
INDEX_SCHEMA: wwj
INDEX_NAME: idx-1
SEQ_IN_INDEX: 1
COLUMN_NAME: idt4
COLLATION: A
CARDINALITY: 8
SUB_PART: NULL
PACKED: NULL
NULLABLE:
INDEX_TYPE: BTREE
COMMENT:
INDEX_COMMENT:
5.USER_PRIVILEGES
用户权限信息
+-----------------------------+---------------+-------------------------+--------------+
| GRANTEE | TABLE_CATALOG | PRIVILEGE_TYPE | IS_GRANTABLE |
+-----------------------------+---------------+-------------------------+--------------+
|
'root'@'localhost' | def | SELECT | YES |
|
'root'@'localhost' | def | INSERT | YES |
|
'root'@'localhost' | def | UPDATE | YES |
|
'root'@'localhost' | def | DELETE | YES |
|
'root'@'localhost' | def | CREATE | YES |
|
'root'@'localhost' | def | DROP | YES |
|
'root'@'localhost' | def | RELOAD | YES |
|
'root'@'localhost' | def | SHUTDOWN | YES |
|
'root'@'localhost' | def | PROCESS | YES |
|
'root'@'localhost' | def | FILE | YES |
|
'root'@'localhost' | def | REFERENCES | YES |
|
'root'@'localhost' | def | INDEX | YES |
|
'root'@'localhost' | def | ALTER | YES |
|
'root'@'localhost' | def | SHOW DATABASES | YES |
|
'root'@'localhost' | def | SUPER | YES |
|
'root'@'localhost' | def | CREATE TEMPORARY TABLES | YES |
|
'root'@'localhost' | def | LOCK TABLES | YES |
|
'root'@'localhost' | def | EXECUTE | YES |
|
'root'@'localhost' | def | REPLICATION SLAVE | YES |
|
'root'@'localhost' | def | REPLICATION CLIENT | YES |
|
'root'@'localhost' | def | CREATE VIEW | YES |
|
'root'@'localhost' | def | SHOW VIEW | YES |
|
'root'@'localhost' | def | CREATE ROUTINE | YES |
|
'root'@'localhost' | def | ALTER ROUTINE | YES |
|
'root'@'localhost' | def | CREATE USER | YES |
|
'root'@'localhost' | def | EVENT | YES |
|
'root'@'localhost' | def | TRIGGER | YES |
|
'root'@'localhost' | def | CREATE TABLESPACE | YES |
|
'mysql.session'@'localhost' | def | SUPER | NO |
|
'mysql.sys'@'localhost' | def | USAGE | NO |
|
'REPL_USER'@'109.115.12.41' | def | REPLICATION SLAVE | NO |
|
'REPL_USER'@'109.115.12.42' | def | REPLICATION SLAVE | NO |
|
'REPL_USER'@'109.115.12.%' | def | REPLICATION SLAVE | NO |
|
'REPL_USER'@'109.115.12.%' | def | REPLICATION CLIENT | NO |
|
'root'@'%' | def | SELECT | NO |
|
'root'@'%' | def | INSERT | NO |
|
'root'@'%' | def | UPDATE | NO |
|
'root'@'%' | def | DELETE | NO |
|
'root'@'%' | def | CREATE | NO |
|
'root'@'%' | def | DROP | NO |
|
'root'@'%' | def | RELOAD | NO |
|
'root'@'%' | def | SHUTDOWN | NO |
|
'root'@'%' | def | PROCESS | NO |
|
'root'@'%' | def | FILE | NO |
|
'root'@'%' | def | REFERENCES | NO |
|
'root'@'%' | def | INDEX | NO |
|
'root'@'%' | def | ALTER | NO |
|
'root'@'%' | def | SHOW DATABASES | NO |
|
'root'@'%' | def | SUPER | NO |
|
'root'@'%' | def | CREATE TEMPORARY TABLES | NO |
|
'root'@'%' | def | LOCK TABLES | NO |
|
'root'@'%' | def | EXECUTE | NO |
|
'root'@'%' | def | REPLICATION SLAVE | NO |
|
'root'@'%' | def | REPLICATION CLIENT | NO |
|
'root'@'%' | def | CREATE VIEW | NO |
|
'root'@'%' | def | SHOW VIEW | NO |
|
'root'@'%' | def | CREATE ROUTINE | NO |
|
'root'@'%' | def | ALTER ROUTINE | NO |
|
'root'@'%' | def | CREATE USER | NO |
|
'root'@'%' | def | EVENT | NO |
|
'root'@'%' | def | TRIGGER | NO |
|
'root'@'%' | def | CREATE TABLESPACE | NO |
+-----------------------------+---------------+-------------------------+--------------+
6.SCHEMA_PRIVILEGES
数据库权限信息
+-----------------------------+---------------+--------------------+----------------+--------------+
| GRANTEE | TABLE_CATALOG | TABLE_SCHEMA | PRIVILEGE_TYPE | IS_GRANTABLE |
+-----------------------------+---------------+--------------------+----------------+--------------+
| 'mysql.sys'@'localhost' | def | sys | TRIGGER | NO |
| 'mysql.session'@'localhost' | def | performance_schema | SELECT | NO |
+-----------------------------+---------------+--------------------+----------------+--------------+
7.TABLE_PRIVILEGES
表权限信息
*************************** 3. row ***************************
GRANTEE:
'wwj'@'%'
TABLE_CATALOG: def
TABLE_SCHEMA: wwj
TABLE_NAME: t3
PRIVILEGE_TYPE: SELECT
IS_GRANTABLE: NO
8.COLUMN_PRIVILEGES
关于列权限信息
9.CHARACTER_SETS
mysql可用字符集
10.TABLE_CONSTRAINTS
表的约束信息
11.KEY_COLUMN_USAGE
描述了具有约束的列的信息
*************************** 79. row ***************************
CONSTRAINT_CATALOG: def
CONSTRAINT_SCHEMA: wwj2
CONSTRAINT_NAME: PRIMARY
TABLE_CATALOG: def
TABLE_SCHEMA: wwj2
TABLE_NAME: t1
COLUMN_NAME: id
ORDINAL_POSITION: 1
POSITION_IN_UNIQUE_CONSTRAINT: NULL
REFERENCED_TABLE_SCHEMA: NULL
REFERENCED_TABLE_NAME: NULL
REFERENCED_COLUMN_NAME: NULL
12.ROUTINES
记录了存储过程和函数的信息
13.VIEWS
记录了数据库中的视图信息,需要有show views权限
*************************** 1. row ***************************
TABLE_CATALOG: def
TABLE_SCHEMA: sys
TABLE_NAME: host_summary
VIEW_DEFINITION: select if(isnull(`performance_schema`.`accounts`.`HOST`),'background',`performance_schema`.`accounts`.`HOST`) AS `host`,sum(`stmt`.`total`) AS `statements`,`sys`.`format_time`(sum(`stmt`.`total_latency`)) AS `statement_latency`,`sys`.`format_time`(ifnull((sum(`stmt`.`total_latency`) / nullif(sum(`stmt`.`total`),0)),0)) AS `statement_avg_latency`,sum(`stmt`.`full_scans`) AS `table_scans`,sum(`io`.`ios`) AS `file_ios`,`sys`.`format_time`(sum(`io`.`io_latency`)) AS `file_io_latency`,sum(`performance_schema`.`accounts`.`CURRENT_CONNECTIONS`) AS `current_connections`,sum(`performance_schema`.`accounts`.`TOTAL_CONNECTIONS`) AS `total_connections`,count(distinct `performance_schema`.`accounts`.`USER`) AS `unique_users`,`sys`.`format_bytes`(sum(`mem`.`current_allocated`)) AS `current_memory`,`sys`.`format_bytes`(sum(`mem`.`total_allocated`)) AS `total_memory_allocated` from (((`performance_schema`.`accounts` join `sys`.`x$host_summary_by_statement_latency` `stmt` on((`performance_schema`.`accounts`.`HOST` = `stmt`.`host`))) join `sys`.`x$host_summary_by_file_io` `io` on((`performance_schema`.`accounts`.`HOST` = `io`.`host`))) join `sys`.`x$memory_by_host_by_current_bytes` `mem` on((`performance_schema`.`accounts`.`HOST` = `mem`.`host`))) group by if(isnull(`performance_schema`.`accounts`.`HOST`),'background',`performance_schema`.`accounts`.`HOST`)
CHECK_OPTION: NONE
IS_UPDATABLE:
DEFINER:
mysql.sys@localhost
SECURITY_TYPE: INVOKER
CHARACTER_SET_CLIENT: utf8
COLLATION_CONNECTION: utf8_general_ci
14.TRIGGERS
提供了数据库中触发器的信息
*************************** 1. row ***************************
TRIGGER_CATALOG: def
TRIGGER_SCHEMA: sys
TRIGGER_NAME: sys_config_insert_set_user
EVENT_MANIPULATION: INSERT
EVENT_OBJECT_CATALOG: def
EVENT_OBJECT_SCHEMA: sys
EVENT_OBJECT_TABLE: sys_config
ACTION_ORDER: 1
ACTION_CONDITION: NULL
ACTION_STATEMENT: BEGIN IF @sys.ignore_sys_config_triggers != true AND NEW.set_by IS NULL THEN SET NEW.set_by = USER(); END IF; END
ACTION_ORIENTATION: ROW
ACTION_TIMING: BEFORE
ACTION_REFERENCE_OLD_TABLE: NULL
ACTION_REFERENCE_NEW_TABLE: NULL
ACTION_REFERENCE_OLD_ROW: OLD
ACTION_REFERENCE_NEW_ROW: NEW
CREATED: 2018-04-06 10:15:16.30
SQL_MODE:
DEFINER:
mysql.sys@localhost
CHARACTER_SET_CLIENT: utf8
COLLATION_CONNECTION: utf8_general_ci
DATABASE_COLLATION: utf8_general_ci
二.performance_schema下常用表
参考:http://www.cnblogs.com/cchust/p/5022148.html
PERFORMANCE_SCHEMA这个功能默认是关闭的。需要设置参数: performance_schema 才可以启动该功能,这个参数是静态参数,只能写在my.cnf 中 不能动态修改。
1.配置表
(1).set_actors
用于配置user维度的监控,默认情况下监控所有用户线程
+------+------+------+---------+---------+
| HOST | USER | ROLE | ENABLED | HISTORY |
+------+------+------+---------+---------+
| % | % | % | YES | YES |
+------+------+------+---------+---------+
(2).setup_consumers
表用于配置事件的消费者类型,即收集的事件最终会写入到哪些统计表中。
+----------------------------------+---------+
| NAME | ENABLED |
+----------------------------------+---------+
| events_stages_current | NO |
| events_stages_history | NO |
| events_stages_history_long | NO |
| events_statements_current | YES |
| events_statements_history | YES |
| events_statements_history_long | NO |
| events_transactions_current | NO |
| events_transactions_history | NO |
| events_transactions_history_long | NO |
| events_waits_current | NO |
| events_waits_history | NO |
| events_waits_history_long | NO |
| global_instrumentation | YES |
| thread_instrumentation | YES |
| statements_digest | YES |
+----------------------------------+---------+
(3).setup_instruments
表用于配置一条条具体的instrument,主要包含4大类:idle,stage/xxx,statement/xxx,wait/xxx.
-idle:表示socket空闲的时间
-stage:表示每个语句每个执行阶段的统计
-statement:统计语句维度的信息
-wait:统计各种等待事件
(4).setup_objects
用于配置监控对象,默认情况下所有,mysql,information_schema,performance_schema下的对象不监控,其他DB的对象全部监控
+-------------+--------------------+-------------+---------+-------+
| OBJECT_TYPE | OBJECT_SCHEMA | OBJECT_NAME | ENABLED | TIMED |
+-------------+--------------------+-------------+---------+-------+
| EVENT | mysql | % | NO | NO |
| EVENT | performance_schema | % | NO | NO |
| EVENT | information_schema | % | NO | NO |
| EVENT | % | % | YES | YES |
| FUNCTION | mysql | % | NO | NO |
| FUNCTION | performance_schema | % | NO | NO |
| FUNCTION | information_schema | % | NO | NO |
| FUNCTION | % | % | YES | YES |
| PROCEDURE | mysql | % | NO | NO |
| PROCEDURE | performance_schema | % | NO | NO |
| PROCEDURE | information_schema | % | NO | NO |
| PROCEDURE | % | % | YES | YES |
| TABLE | mysql | % | NO | NO |
| TABLE | performance_schema | % | NO | NO |
| TABLE | information_schema | % | NO | NO |
| TABLE | % | % | YES | YES |
| TRIGGER | mysql | % | NO | NO |
| TRIGGER | performance_schema | % | NO | NO |
| TRIGGER | information_schema | % | NO | NO |
| TRIGGER | % | % | YES | YES |
+-------------+--------------------+-------------+---------+-------+
(5).setup_timers
配置每种类型统计的时间单位
+-------------+-------------+
| NAME | TIMER_NAME |
+-------------+-------------+
| idle | MICROSECOND |
| wait | CYCLE |
| stage | NANOSECOND |
| statement | NANOSECOND |
| transaction | NANOSECOND |
+-------------+-------------+
2.instance表
(1).file_instances
表中记录了系统中打开了文件的对象,open_count显示当前文件打开的数目
+-------------------------------------------+--------------------------------------+------------+
| FILE_NAME | EVENT_NAME | OPEN_COUNT |
+-------------------------------------------+--------------------------------------+------------+
| /usr/local/mysql/share/english/errmsg.sys | wait/io/file/sql/ERRMSG | 0 |
| /usr/local/mysql/share/charsets/Index.xml | wait/io/file/mysys/charset | 0 |
| /mysql/mysql3306/mysql3306/ibdata1 | wait/io/file/innodb/innodb_data_file | 3 |
+-------------------------------------------+--------------------------------------+------------+
(2).mutex_instances
表中记录了系统中使用互斥量对象的所有记录,LOCKED_BY_THREAD_ID显示哪个线程正持有mutex,若没有线程持有,则为NULL。
+----------------------------------------+-----------------------+---------------------+
| NAME | OBJECT_INSTANCE_BEGIN | LOCKED_BY_THREAD_ID |
+----------------------------------------+-----------------------+---------------------+
| wait/synch/mutex/mysys/THR_LOCK_heap | 32492032 | NULL |
| wait/synch/mutex/mysys/THR_LOCK_net | 32491776 | NULL |
| wait/synch/mutex/mysys/THR_LOCK_myisam | 32491712 | NULL |
+----------------------------------------+-----------------------+---------------------+
(3).rwlock_instances
记录了系统中使用读写锁对象的所有记录
WRITE_LOCKED_BY_THREAD_ID为正在持有该对象的thread_id,若没有线程持有,则为NULL
READ_LOCKED_BY_COUNT为记录了同时有多少个读者持有读锁
+-------------------------------------------------------+-----------------------+---------------------------+----------------------+
| NAME | OBJECT_INSTANCE_BEGIN | WRITE_LOCKED_BY_THREAD_ID | READ_LOCKED_BY_COUNT |
+-------------------------------------------------------+-----------------------+---------------------------+----------------------+
| wait/synch/rwlock/session/LOCK_srv_session_collection | 31736184 | NULL | 0 |
+-------------------------------------------------------+-----------------------+---------------------------+----------------------+
(4).socket_instances
表中记录了thread_id,socket_id,ip和port,其它表可以通过thread_id与socket_instance进行关联,获取IP-PORT信息,能够与应用对接起来。
event_name主要包含3类:
wait/io/socket/sql/server_unix_socket,服务端unix监听socket
wait/io/socket/sql/server_tcpip_socket,服务端tcp监听socket
wait/io/socket/sql/client_connection,客户端socket
+----------------------------------------+-----------------------+-----------+-----------+----+------+--------+
| EVENT_NAME | OBJECT_INSTANCE_BEGIN | THREAD_ID | SOCKET_ID | IP | PORT | STATE |
+----------------------------------------+-----------------------+-----------+-----------+----+------+--------+
| wait/io/socket/sql/server_tcpip_socket | 83218752 | 1 | 22 | :: | 3306 | ACTIVE |
| wait/io/socket/sql/server_unix_socket | 83219072 | 1 | 24 | | 0 | ACTIVE |
| wait/io/socket/sql/client_connection | 83221952 | 63 | 27 | | 0 | IDLE |
| wait/io/socket/sql/client_connection | 83222272 | 64 | 29 | | 0 | IDLE |
| wait/io/socket/sql/client_connection | 83222592 | 65 | 30 | | 0 | ACTIVE |
+----------------------------------------+-----------------------+-----------+-----------+----+------+--------+
3.Wait Event表
events_waits_current #记录了当前线程等待的事件
events_waits_history #记录了每个线程最近等待的10个事件
events_waits_history_long #记录了最近所有线程产生的10000个事件
history表中的事件都是完成了的,没有结束的事件不会加入到history表中.
THREAD_ID:线程ID
EVENT_ID:当前线程的事件ID,和THREAD_ID组成一个Primary Key。
END_EVENT_ID:当事件开始时,这一列被设置为NULL。当事件结束时,再更新为当前的事件ID。
SOURCE:该事件产生时的源码文件
TIMER_START, TIMER_END, TIMER_WAIT:事件开始/结束和等待的时间,单位为皮秒(picoseconds)
OBJECT_SCHEMA, OBJECT_NAME, OBJECT_TYPE视情况而定
对于同步对象(cond, mutex, rwlock),这个3个值均为NULL
对于文件IO对象,OBJECT_SCHEMA为NULL,OBJECT_NAME为文件名,OBJECT_TYPE为FILE
对于SOCKET对象,OBJECT_NAME为该socket的IP:SOCK值
对于表I/O对象,OBJECT_SCHEMA是表的SCHEMA名,OBJECT_NAME是表名,OBJECT_TYPE为TABLE或者TEMPORARY TABLE
NESTING_EVENT_ID:该事件对应的父事件ID
NESTING_EVENT_TYPE:父事件类型(STATEMENT, STAGE, WAIT)
OPERATION:操作类型(lock, read, write)
4.stage event表
events_waits_current
events_stages_history
events_stages_history_long
表中记录了当前线程所处的执行阶段,由于可以知道每个阶段的执行时间,因此通过stage表可以得到SQL在每个阶段消耗的时间。
THREAD_ID:线程ID
EVENT_ID:事件ID
END_EVENT_ID:刚结束的事件ID
SOURCE:源码位置
TIMER_START, TIMER_END, TIMER_WAIT:事件开始/结束和等待的时间,单位为皮秒(picoseconds)
NESTING_EVENT_ID:该事件对应的父事件ID
NESTING_EVENT_TYPE:父事件类型(STATEMENT, STAGE, WAIT)
5.Statement Event
events_statements_current
events_statements_history
events_statements_history_long
Statments表只记录最顶层的请求,SQL语句或是COMMAND,每条语句一行,对于嵌套的子查询或者存储过程不会单独列出。event_name形式为statement/sql/*,或statement/com/*
*************************** 8. row ***************************
THREAD_ID: 67
EVENT_ID: 96
END_EVENT_ID: 96
EVENT_NAME: statement/sql/select
SOURCE: socket_connection.cc:101
TIMER_START: 365640494222296000
TIMER_END: 365640496863080000
TIMER_WAIT: 2640784000
LOCK_TIME: 195000000
SQL_TEXT: select * from events_statements_history
DIGEST: 12bf4ba549a7a86ad0d382bf2cd93f91
DIGEST_TEXT: SELECT * FROM `events_statements_history`
CURRENT_SCHEMA: performance_schema
OBJECT_TYPE: NULL
OBJECT_SCHEMA: NULL
OBJECT_NAME: NULL
OBJECT_INSTANCE_BEGIN: NULL
MYSQL_ERRNO: 0
RETURNED_SQLSTATE: NULL
MESSAGE_TEXT: NULL
ERRORS: 0
WARNINGS: 0
ROWS_AFFECTED: 0
ROWS_SENT: 12
ROWS_EXAMINED: 12
CREATED_TMP_DISK_TABLES: 0
CREATED_TMP_TABLES: 0
SELECT_FULL_JOIN: 0
SELECT_FULL_RANGE_JOIN: 0
SELECT_RANGE: 0
SELECT_RANGE_CHECK: 0
SELECT_SCAN: 1
SORT_MERGE_PASSES: 0
SORT_RANGE: 0
SORT_ROWS: 0
SORT_SCAN: 0
NO_INDEX_USED: 1
NO_GOOD_INDEX_USED: 0
NESTING_EVENT_ID: NULL
NESTING_EVENT_TYPE: NULL
NESTING_EVENT_LEVEL: 0
SQL_TEXT:记录SQL语句
DIGEST:对SQL_TEXT做MD5产生的32位字符串。如果为consumer表中没有打开statement_digest选项,则为NULL。
DIGEST_TEXT:将语句中值部分用问号代替,用于SQL语句归类。如果为consumer表中没有打开statement_digest选项,则为NULL。
CURRENT_SCHEMA:默认的数据库名
OBJECT_SCHEMA,OBJECT_NAME,OBJECT_TYPE:保留字段,全部为NULL
ROWS_AFFECTED:影响的数目
ROWS_SENT:返回的记录数
ROWS_EXAMINED:读取的记录数目
CREATED_TMP_DISK_TABLES:创建物理临时表数目
CREATED_TMP_TABLES:创建临时表数目
SELECT_FULL_JOIN:join时,第一个表为全表扫描的数目
SELECT_FULL_RANGE_JOIN:join时,引用表采用range方式扫描的数目
SELECT_RANGE:join时,第一个表采用range方式扫描的数目
SELECT_SCAN:join时,第一个表位全表扫描的数目
SORT_ROWS:排序的记录数目
NESTING_EVENT_ID,NESTING_EVENT_TYPE,保留字段,为NULL。
6.connection表
users,hosts和account表
accounts包含hosts和users的信息。
USER:用户名
HOST:用户的IP
7.Summary
Summary表聚集了各个维度的统计信息包括表维度,索引维度,会话维度,语句维度和锁维度的统计信息。
(1).wait-summary表
events_waits_summary_global_by_event_name
场景:按等待事件类型聚合,每个事件一条记录。
events_waits_summary_by_instance
场景:按等待事件对象聚合,同一种等待事件,可能有多个实例,每个实例有不同的内存地址,因此
event_name+object_instance_begin唯一确定一条记录。
events_waits_summary_by_thread_by_event_name
场景:按每个线程和事件来统计,thread_id+event_name唯一确定一条记录。
COUNT_STAR:事件计数
SUM_TIMER_WAIT:总的等待时间
MIN_TIMER_WAIT:最小等待时间
MAX_TIMER_WAIT:最大等待时间
AVG_TIMER_WAIT:平均等待时间
(2).stage-summary表
events_stages_summary_by_thread_by_event_name
events_stages_summary_global_by_event_name
与前面类似
(3).statements-summary表
events_statements_summary_by_thread_by_event_name表和events_statements_summary_global_by_event_name表与前面类似。对于events_statements_summary_by_digest表,
FIRST_SEEN_TIMESTAMP:第一个语句执行的时间
LAST_SEEN_TIMESTAMP:最后一个语句执行的时间
场景:用于统计某一段时间内top SQL
(4).file I/O summary表
file_summary_by_event_name [按事件类型统计]
file_summary_by_instance [按具体文件统计]
场景:物理IO维度
FILE_NAME:具体文件名,比如:/u01/my3306/data/tcbuyer_0168/tc_biz_order_2695.ibd
EVENT_NAME:事件名,比如:wait/io/file/innodb/innodb_data_file
COUNT_STAR,SUM_TIMER_WAIT,MIN_TIMER_WAIT,AVG_TIMER_WAIT,MAX_TIMER_WAIT
统计IO操作
COUNT_READ,SUM_TIMER_READ,MIN_TIMER_READ,AVG_TIMER_READ,MAX_TIMER_READ, SUM_NUMBER_OF_BYTES_READ
统计读
COUNT_WRITE,SUM_TIMER_WRITE,MIN_TIMER_WRITE,AVG_TIMER_WRITE,MAX_TIMER_WRITE, SUM_NUMBER_OF_BYTES_WRITE
统计写
COUNT_MISC,SUM_TIMER_MISC,MIN_TIMER_MISC,AVG_TIMER_MISC,MAX_TIMER_MISC
统计其他IO事件,比如create,delete,open,close等
(5).Table I/O and Lock Wait Summaries-表
table_io_waits_summary_by_table
根据wait/io/table/sql/handler,聚合每个表的I/O操作,[逻辑IO]
COUNT_STAR,SUM_TIMER_WAIT,MIN_TIMER_WAIT,AVG_TIMER_WAIT,MAX_TIMER_WAIT
统计IO操作
COUNT_READ,SUM_TIMER_WAIT,MIN_TIMER_WAIT,AVG_TIMER_WAIT,MAX_TIMER_WAIT
统计读
COUNT_WRITE,SUM_TIMER_WRITE,MIN_TIMER_WRITE,AVG_TIMER_WRITE, MAX_TIMER_WRITE
统计写
COUNT_FETCH,SUM_TIMER_FETCH,MIN_TIMER_FETCH,AVG_TIMER_FETCH, MAX_TIMER_FETCH
与读相同
COUNT_INSERT,SUM_TIMER_INSERT,MIN_TIMER_INSERT,AVG_TIMER_INSERT,MAX_TIMER_INSERT
INSERT统计,相应的还有DELETE和UPDATE统计。
(6).table_io_waits_summary_by_index_usage
与table_io_waits_summary_by_table类似,按索引维度统计
(7).table_lock_waits_summary_by_table
聚合了表锁等待事件,包括internal lock 和 external lock。
internal lock通过SQL层函数thr_lock调用,OPERATION值为:
read normal
read with shared locks
read high priority
read no insert
write allow write
write concurrent insert
write delayed
write low priority
write normal
external lock则通过接口函数handler::external_lock调用存储引擎层,
OPERATION列的值为:
read external
write external
(8).Connection Summaries表
events_waits_summary_by_account_by_event_name
events_waits_summary_by_user_by_event_name
events_waits_summary_by_host_by_event_name
events_stages_summary_by_account_by_event_name
events_stages_summary_by_user_by_event_name
events_stages_summary_by_host_by_event_name
events_statements_summary_by_account_by_event_name
events_statements_summary_by_user_by_event_name
events_statements_summary_by_host_by_event_name
(9).socket-summaries表
socket_summary_by_instance
socket_summary_by_event_name
其它表
performance_timers: 系统支持的统计时间单位
threads: 监视服务端的当前运行的线程
http://www.cnblogs.com/cchust/p/5061131.html
三.mysql数据库常用表
1、user表: 用户列、权限列、安全列、资源控制列
2、db表 : 用户列、权限列
3、table_priv表
4、columns_priv表
5、proc_priv表
四.sys数据库常用表
1.host视图
(1).host_summary;
统计了host的SQL执行信息,文件io信息和连接信息
? host : 监听连接过的主机
? statements : 当前主机执行的语句总数
? statement_latency : 语句等待时间(延迟时间)
? statement_avg_latency : 执行语句平均延迟时间
? table_scans : 表扫描次数
? file_ios : io时间总数
? file_io_latency : 文件io延迟
? current_connections : 当前连接数
? total_connections : 总链接数
? unique_users : 该主机的唯一用户数
? current_memory : 当前账户分配的内存
? total_memory_allocated : 该主机分配的内存总数
(2).host_summary_by_file_io
统计了host的文件io信息
?host : 主机
?iOS : IO事件总数
?io_latency : IO总的延迟时间
(3).host_summary_by_file_io_type
按照host和event进行分组,统计文件的io信息
?host : 主机
?event_name : IO事件名称
?total : 该主机发生的事件
?total_latency : 该主机发生IO事件总延迟时间
?max_latency : 该主机IO事件中最大的延迟时间
(4).host_summary_by_stages
总计语句stage,由host分组
? host :主机
? event_name :名称
? total :发生的总数
? total_latency : 总的延迟时间
? avg_latency :平均延迟时间
(5).host_summary_by_statement_latency
统计了host,执行SQL语句的信息
? host : 主机
? total : 这个主机的语句总数
? total_latency : 这个主机总的延迟时间
? max_latency : 主机最大的延迟时间
? lock_latency : 等待锁的锁延迟时间
? rows_sent : 该主机通过语句返回的总行数
? rows_examined : 在存储引擎上通过语句返回的行数
? rows_affected : 该主机通过语句影响的总行数
? full_scans : 全表扫描的语句总数
(6).host_summary_by_statement_type
按照host和sql类型进行分组,统计SQL语句执行信息
? host: 主机
? statement: 最后的语句事件名称
? total: sql语句总数
? total_latency: sql语句总延迟数
? max_latency: 最大的sql语句延迟数
? lock_latency: 锁延迟总数
? rows_sent: 语句返回的行总数
? rows_examined: 通过存储引擎的sql语句的读取的总行数
? rows_affected: 语句影响的总行数
? full_scans : 全表扫描的语句事件总数
2.innodb视图
(1).innodb_buffer_stats_by_schema
通过数据库统计innodb引擎的innodb缓存
? object_schema: 数据库名称
? allocated: 分配给当前数据库的总的字节数
? data: 分配给当前数据库的数据字节数
? pages: 分配给当前数据库的总页数
? pages_hashed: 分配给当前数据库的hash页数
? pages_old: 分配给当前数据库的旧页数
? rows_cached: 当前数据库缓存的行数
(2).innodb_buffer_stats_by_table
每个表innodb引擎的innodb缓存
? object_schema: 数据库名称
? object_name: 表名称
? allocated: 分配给表的总字节数
? data: 分配该表的数据字节数
? pages: 分配给表的页数
? pages_hashed: 分配给表的hash页数
? pages_old : 分配给表的旧页数
? rows_cached : 表的行缓存数
(3).innodb_lock_waits
总计了innodb锁等待
? wait_started : 锁等待发生的时间
? wait_age : 锁已经等待了多长时间
? wait_age_secs : 以秒为单位显示锁已经等待的时间(5.7.9中添加此列)
? locked_table : 被锁的表
? locked_index : 被锁住的索引
? locked_type : 锁类型
? waiting_trx_id : 正在等待的事务ID
? waiting_trx_started : 等待事务开始的时间
? waiting_trx_age : 已经等待事务多长时间
上述就是小编为大家分享的mysql的常用系统表和视图有哪些了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注亿速云行业资讯频道。