1
.. _slow_log_in_memory:
7
The feature is used to save slow queries in memory. This feature adds an ``INFORMATION_SCHEMA.SLOW_LOG`` table to show the latest queries, a variable to limit the max memory used, and status to show the status of memory used.
9
There are two plugins in the feature. They can be installed by command ``"install plugin SLOWLOG_IN_MEMORY_AUDIT soname 'slowlog_in_memory.so'"`` and ``"install plugin SLOW_LOG soname 'slowlog_in_memory.so'"``, they work by keeping one list in memory.
16
*Percona*; *Percona* added an ``INFORMATION_SCHEMA`` table and the :variable:`slowlog_in_memory_audit_max_memory` and the :status:`slow_log_current_memory`.
21
.. variable:: slowlog_in_memory_audit_max_memory
31
The variable is used to limit the max-memory used for slow log. If a new slow query will make the `current_memory` bigger than this value, the most eldest items will be discarded, until there is enough memory for new item. When the value is decrease dynamically, it behaves the same.
36
One new status variable was introduced by this feature.
38
.. variable:: slow_log_current_memory
43
The variable showes the current memory used for the slow queries. It can never be bigger than the `slowlog_in_memory_audit_max_memory` variable.
46
INFORMATION_SCHEMA Tables
47
=========================
49
.. table:: INFORMATION_SCHEMA.SLOW_LOG
51
:column EVENT_ID: A global increment id for every record in the table, can be used to identify every one.
52
:column TIMESTAMP: The timestamp when the query stop.
53
:column THREAD_ID: The thread_id of the query.
54
:column DB: The current database() of the query, may be NULL.
55
:column INNODB_TRX_ID: The Innodb_trx_id if InnoDB is used, may be NULL.
56
:column ERROR: The errno of the query, 0 means no error.
57
:column MS_QUERY_TIME: The query_exec_time of the query, in second.
58
:column QUERY: The query statement.
60
This table holds the lastest slow queries.
64
mysql> select * from information_schema.slow_log \G
65
*************************** 1. row ***************************
73
QUERY: select sleep(3)