PDF (A4) - 35.2Mb
Man Pages (TGZ) - 256.4Kb
Man Pages (Zip) - 361.2Kb
Info (Gzip) - 3.4Mb
Info (Zip) - 3.4Mb
MySQL Globalization
MySQL Information Schema
MySQL Installation Guide
MySQL and Linux/Unix
MySQL and macOS
MySQL Partitioning
MySQL Performance Schema
MySQL Replication
Using the MySQL Yum Repository
MySQL Restrictions and Limitations
Security in MySQL
MySQL and Solaris
Building MySQL from Source
Starting and Stopping MySQL
MySQL Tutorial
MySQL and Windows
MySQL NDB Cluster 7.5
Thethreads table contains a row for each server thread. Each row contains information about a thread and indicates whether monitoring is enabled for it. For the Performance Schema to monitor a thread, these things must be true:
The
thread_instrumentationconsumer in thesetup_consumerstable must beYES.The
threads.INSTRUMENTEDcolumn must beYES.Monitoring occurs only for those thread events produced from instruments that are enabled in the
setup_instrumentstable.
Thethreads table also indicates for each server thread whether to perform historical event logging. This includes wait, stage, statement, and transaction events and affects logging to these tables:
events_waits_historyevents_waits_history_longevents_stages_historyevents_stages_history_longevents_statements_historyevents_statements_history_longevents_transactions_historyevents_transactions_history_longFor historical event logging to occur, these things must be true:
The appropriate history-related consumers in the
setup_consumerstable must be enabled. For example, wait event logging in theevents_waits_historyandevents_waits_history_longtables requires the correspondingevents_waits_historyandevents_waits_history_longconsumers to beYES.The
threads.HISTORYcolumn must beYES.Logging occurs only for those thread events produced from instruments that are enabled in the
setup_instrumentstable.
For foreground threads (resulting from client connections), the initial values of theINSTRUMENTED andHISTORY columns inthreads table rows are determined by whether the user account associated with a thread matches any row in thesetup_actors table. The values come from theENABLED andHISTORY columns of the matchingsetup_actors table row.
For background threads, there is no associated user.INSTRUMENTED andHISTORY areYES by default andsetup_actors is not consulted.
The initialsetup_actors contents look like this:
mysql> SELECT * FROM performance_schema.setup_actors;+------+------+------+---------+---------+| HOST | USER | ROLE | ENABLED | HISTORY |+------+------+------+---------+---------+| % | % | % | YES | YES |+------+------+------+---------+---------+ TheHOST andUSER columns should contain a literal host or user name, or'%' to match any name.
TheENABLED andHISTORY columns indicate whether to enable instrumentation and historical event logging for matching threads, subject to the other conditions described previously.
When the Performance Schema checks for a match for each new foreground thread insetup_actors, it tries to find more specific matches first, using theUSER andHOST columns (ROLE is unused):
Rows with
USER='andliteral'HOST='.literal'Rows with
USER='andliteral'HOST='%'.Rows with
USER='%'andHOST='.literal'Rows with
USER='%'andHOST='%'.
The order in which matching occurs matters because different matchingsetup_actors rows can have differentUSER andHOST values. This enables instrumenting and historical event logging to be applied selectively per host, user, or account (user and host combination), based on theENABLED andHISTORY column values:
When the best match is a row with
ENABLED=YES, theINSTRUMENTEDvalue for the thread becomesYES. When the best match is a row withHISTORY=YES, theHISTORYvalue for the thread becomesYES.When the best match is a row with
ENABLED=NO, theINSTRUMENTEDvalue for the thread becomesNO. When the best match is a row withHISTORY=NO, theHISTORYvalue for the thread becomesNO.When no match is found, the
INSTRUMENTEDandHISTORYvalues for the thread becomeNO.
TheENABLED andHISTORY columns insetup_actors rows can be set toYES orNO independent of one another. This means you can enable instrumentation separately from whether you collect historical events.
By default, monitoring and historical event collection are enabled for all new foreground threads because thesetup_actors table initially contains a row with'%' for bothHOST andUSER. To perform more limited matching such as to enable monitoring only for some foreground threads, you must change this row because it matches any connection, and add rows for more specificHOST/USER combinations.
Suppose that you modifysetup_actors as follows:
UPDATE performance_schema.setup_actorsSET ENABLED = 'NO', HISTORY = 'NO'WHERE HOST = '%' AND USER = '%';INSERT INTO performance_schema.setup_actors(HOST,USER,ROLE,ENABLED,HISTORY)VALUES('localhost','joe','%','YES','YES');INSERT INTO performance_schema.setup_actors(HOST,USER,ROLE,ENABLED,HISTORY)VALUES('hosta.example.com','joe','%','YES','NO');INSERT INTO performance_schema.setup_actors(HOST,USER,ROLE,ENABLED,HISTORY)VALUES('%','sam','%','NO','YES'); TheUPDATE statement changes the default match to disable instrumentation and historical event collection. TheINSERT statements add rows for more specific matches.
Now the Performance Schema determines how to set theINSTRUMENTED andHISTORY values for new connection threads as follows:
If
joeconnects from the local host, the connection matches the first inserted row. TheINSTRUMENTEDandHISTORYvalues for the thread becomeYES.If
joeconnects fromhosta.example.com, the connection matches the second inserted row. TheINSTRUMENTEDvalue for the thread becomesYESand theHISTORYvalue becomesNO.If
joeconnects from any other host, there is no match. TheINSTRUMENTEDandHISTORYvalues for the thread becomeNO.If
samconnects from any host, the connection matches the third inserted row. TheINSTRUMENTEDvalue for the thread becomesNOand theHISTORYvalue becomesYES.For any other connection, the row with
HOSTandUSERset to'%'matches. This row now hasENABLEDandHISTORYset toNO, so theINSTRUMENTEDandHISTORYvalues for the thread becomeNO.
Modifications to thesetup_actors table affect only foreground threads created subsequent to the modification, not existing threads. To affect existing threads, modify theINSTRUMENTED andHISTORY columns ofthreads table rows.
PDF (A4) - 35.2Mb
Man Pages (TGZ) - 256.4Kb
Man Pages (Zip) - 361.2Kb
Info (Gzip) - 3.4Mb
Info (Zip) - 3.4Mb
MySQL Globalization
MySQL Information Schema
MySQL Installation Guide
MySQL and Linux/Unix
MySQL and macOS
MySQL Partitioning
MySQL Performance Schema
MySQL Replication
Using the MySQL Yum Repository
MySQL Restrictions and Limitations
Security in MySQL
MySQL and Solaris
Building MySQL from Source
Starting and Stopping MySQL
MySQL Tutorial
MySQL and Windows
MySQL NDB Cluster 7.5