~dingqi-lxb/percona-server/5.5_log_queries_in_memory

« back to all changes in this revision

Viewing changes to doc/source/diagnostics/slow_log_in_memory.rst

  • Committer: dingqi.lxb at taobao
  • Date: 2012-01-01 03:55:05 UTC
  • Revision ID: dingqi.lxb@taobao.com-20120101035505-dx78chfh2065mkzm
add slowlog_in_memory.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
.. _slow_log_in_memory:
 
2
 
 
3
=================
 
4
 Slow Log In Memory
 
5
=================
 
6
 
 
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. 
 
8
 
 
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. 
 
10
 
 
11
 
 
12
Other Information
 
13
=================
 
14
 
 
15
  * Author/Origin:
 
16
     *Percona*; *Percona* added an ``INFORMATION_SCHEMA`` table and the :variable:`slowlog_in_memory_audit_max_memory` and the :status:`slow_log_current_memory`.
 
17
 
 
18
System Variables
 
19
================
 
20
 
 
21
.. variable:: slowlog_in_memory_audit_max_memory
 
22
 
 
23
     :cli: Yes
 
24
     :conf: Yes
 
25
     :scope: Global
 
26
     :dyn: Yes
 
27
     :vartype: ULONG
 
28
     :default: 1M
 
29
     :range: 0 - 1G
 
30
 
 
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.
 
32
 
 
33
Status Variables
 
34
================
 
35
 
 
36
One new status variable was introduced by this feature.
 
37
 
 
38
.. variable:: slow_log_current_memory
 
39
 
 
40
     :vartype: ULONG
 
41
     :scope: Global
 
42
 
 
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.
 
44
 
 
45
 
 
46
INFORMATION_SCHEMA Tables
 
47
=========================
 
48
 
 
49
.. table:: INFORMATION_SCHEMA.SLOW_LOG
 
50
 
 
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.
 
59
 
 
60
This table holds the lastest slow queries.
 
61
 
 
62
Example: ::
 
63
 
 
64
  mysql> select * from information_schema.slow_log \G
 
65
  *************************** 1. row ***************************
 
66
       EVENT_ID: 1
 
67
      TIMESTAMP: 1323753896
 
68
      THREAD_ID: 2
 
69
             DB: test
 
70
  INNODB_TRX_ID: NULL
 
71
          ERRNO: 0
 
72
  MS_QUERY_TIME: 3001
 
73
          QUERY: select sleep(3)
 
74