Rechercher dans le manuel MySQL
26.12.5 Performance Schema Stage Event Tables
[+/-]
The Performance Schema instruments stages, which are steps
during the statement-execution process, such as parsing a
statement, opening a table, or performing a
filesort
operation. Stages correspond to the
thread states displayed by SHOW
PROCESSLIST
or that are visible in the
INFORMATION_SCHEMA.PROCESSLIST
table. Stages begin and end when state values change.
Within the event hierarchy, wait events nest within stage events, which nest within statement events, which nest within transaction events.
These tables store stage events:
events_stages_current
: The current stage event for each thread.events_stages_history
: The most recent stage events that have ended per thread.events_stages_history_long
: The most recent stage events that have ended globally (across all threads).
The following sections describe the stage event tables. There are also summary tables that aggregate information about stage events; see Section 26.12.16.2, “Stage Summary Tables”.
For more information about the relationship between the three stage event tables, see Section 26.9, “Performance Schema Tables for Current and Historical Events”.
Configuring Stage Event Collection
To control whether to collect stage events, set the state of the relevant instruments and consumers:
The
setup_instruments
table contains instruments with names that begin withstage
. Use these instruments to enable or disable collection of individual stage event classes.The
setup_consumers
table contains consumer values with names corresponding to the current and historical stage event table names. Use these consumers to filter collection of stage events.
Other than those instruments that provide statement progress information, the stage instruments are disabled by default. For example:
- FROM performance_schema.setup_instruments
- +----------------------------------------------------+---------+-------+
- | NAME | ENABLED | TIMED |
- +----------------------------------------------------+---------+-------+
- +----------------------------------------------------+---------+-------+
Stage event instruments that provide statement progress information are enabled and timed by default:
- FROM performance_schema.setup_instruments
- +------------------------------------------------------+---------+-------+
- | NAME | ENABLED | TIMED |
- +------------------------------------------------------+---------+-------+
- +------------------------------------------------------+---------+-------+
The stage consumers are disabled by default:
- FROM performance_schema.setup_consumers
- +----------------------------+---------+
- | NAME | ENABLED |
- +----------------------------+---------+
- +----------------------------+---------+
To control stage event collection at server startup, use lines
like these in your my.cnf
file:
Enable:
[mysqld] performance-schema-instrument='stage/%=ON' performance-schema-consumer-events-stages-current=ON performance-schema-consumer-events-stages-history=ON performance-schema-consumer-events-stages-history-long=ON
Disable:
[mysqld] performance-schema-instrument='stage/%=OFF' performance-schema-consumer-events-stages-current=OFF performance-schema-consumer-events-stages-history=OFF performance-schema-consumer-events-stages-history-long=OFF
To control stage event collection at runtime, update the
setup_instruments
and
setup_consumers
tables:
Enable:
Disable:
To collect only specific stage events, enable only the corresponding stage instruments. To collect stage events only for specific stage event tables, enable the stage instruments but only the stage consumers corresponding to the desired tables.
For additional information about configuring event collection, see Section 26.3, “Performance Schema Startup Configuration”, and Section 26.4, “Performance Schema Runtime Configuration”.
Stage Event Progress Information
The Performance Schema stage event tables contain two columns that, taken together, provide a stage progress indicator for each row:
WORK_COMPLETED
: The number of work units completed for the stageWORK_ESTIMATED
: The number of work units expected for the stage
Each column is NULL
if no progress
information is provided for an instrument. Interpretation of the
information, if it is available, depends entirely on the
instrument implementation. The Performance Schema tables provide
a container to store progress data, but make no assumptions
about the semantics of the metric itself:
A “work unit” is an integer metric that increases over time during execution, such as the number of bytes, rows, files, or tables processed. The definition of “work unit” for a particular instrument is left to the instrumentation code providing the data.
The
WORK_COMPLETED
value can increase one or many units at a time, depending on the instrumented code.The
WORK_ESTIMATED
value can change during the stage, depending on the instrumented code.
Instrumentation for a stage event progress indicator can implement any of the following behaviors:
No progress instrumentation
This is the most typical case, where no progress data is provided. The
WORK_COMPLETED
andWORK_ESTIMATED
columns are bothNULL
.Unbounded progress instrumentation
Only the
WORK_COMPLETED
column is meaningful. No data is provided for theWORK_ESTIMATED
column, which displays 0.By querying the
events_stages_current
table for the monitored session, a monitoring application can report how much work has been performed so far, but cannot report whether the stage is near completion. Currently, no stages are instrumented like this.Bounded progress instrumentation
The
WORK_COMPLETED
andWORK_ESTIMATED
columns are both meaningful.This type of progress indicator is appropriate for an operation with a defined completion criterion, such as the table-copy instrument described later. By querying the
events_stages_current
table for the monitored session, a monitoring application can report how much work has been performed so far, and can report the overall completion percentage for the stage, by computing theWORK_COMPLETED
/WORK_ESTIMATED
ratio.
The stage/sql/copy to tmp table
instrument
illustrates how progress indicators work. During execution of an
ALTER TABLE
statement, the
stage/sql/copy to tmp table
stage is used,
and this stage can execute potentially for a long time,
depending on the size of the data to copy.
The table-copy task has a defined termination (all rows copied),
and the stage/sql/copy to tmp table
stage is
instrumented to provided bounded progress information: The work
unit used is number of rows copied,
WORK_COMPLETED
and
WORK_ESTIMATED
are both meaningful, and their
ratio indicates task percentage complete.
To enable the instrument and the relevant consumers, execute these statements:
To see the progress of an ongoing ALTER
TABLE
statement, select from the
events_stages_current
table.
Traduction non disponible
Le manuel MySQL n'est pas encore traduit en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Document créé le 26/06/2006, dernière modification le 26/10/2018
Source du document imprimé : https://www.gaudry.be/mysql-rf-performance-schema-stage-tables.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.