•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  and WORK_ESTIMATED  columns are both NULL . 

•Unbounded progress instrumentation 

Only the WORK_COMPLETED  column is meaningful. No data is provided for the WORK_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  and WORK_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 the WORK_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: 

UPDATE performance_schema.setup_instruments SET ENABLED=’YES’ WHERE NAME=’stage/sql/copy to tmp table’; UPDATE performance_schema.setup_consumers SET ENABLED=’YES’ WHERE NAME LIKE ’events_stages_%’; 

To see the progress of an ongoing ALTER TABLE  statement, select from the events_stages_current table. 

## 27.12.5.1 The events_stages_current Table 

The events_stages_current  table contains current stage events. The table stores one row per thread showing the current status of the thread’s most recent monitored stage event, so there is no system variable for configuring the table size. 

Of the tables that contain stage event rows, events_stages_current  is the most fundamental. Other tables that contain stage event rows are logically derived from the current events. For example, the events_stages_history  and events_stages_history_long  tables are collections of the most 

