MySQL  8.0.19
Source Code Documentation
ut_stage_alter_t Class Reference

Class used to report ALTER TABLE progress via performance_schema. More...

#include <ut0stage.h>

Public Member Functions

 ut_stage_alter_t (const dict_index_t *pk)
 Constructor. More...
 
 ~ut_stage_alter_t ()
 Destructor. More...
 
void begin_phase_read_pk (ulint n_sort_indexes)
 Flag an ALTER TABLE start (read primary key phase). More...
 
void n_pk_recs_inc ()
 Increment the number of records in PK (table) with 1. More...
 
void inc (ulint inc_val=1)
 Flag either one record or one page processed, depending on the current phase. More...
 
void end_phase_read_pk ()
 Flag the end of reading of the primary key. More...
 
void begin_phase_sort (double sort_multi_factor)
 Flag the beginning of the sort phase. More...
 
void begin_phase_insert ()
 Flag the beginning of the insert phase. More...
 
void begin_phase_flush (ulint n_flush_pages)
 Flag the beginning of the flush phase. More...
 
void begin_phase_log_index ()
 Flag the beginning of the log index phase. More...
 
void begin_phase_log_table ()
 Flag the beginning of the log table phase. More...
 
void begin_phase_end ()
 Flag the beginning of the end phase. More...
 

Private Types

enum  {
  NOT_STARTED = 0, READ_PK = 1, SORT = 2, INSERT = 3,
  FLUSH = 4, LOG_INDEX = 5, LOG_TABLE = 6, END = 7
}
 Current phase. More...
 

Private Member Functions

void reestimate ()
 Update the estimate of total work to be done. More...
 
void change_phase (const PSI_stage_info *new_stage)
 Change the current phase. More...
 

Private Attributes

PSI_stage_progressm_progress
 Performance schema accounting object. More...
 
const dict_index_tm_pk
 Old table PK. More...
 
ulint m_n_pk_recs
 Number of records in the primary key (table), including delete marked records. More...
 
ulint m_n_pk_pages
 Number of leaf pages in the primary key. More...
 
double m_n_recs_per_page
 Estimated number of records per page in the primary key. More...
 
ulint m_n_sort_indexes
 Number of indexes that are being added. More...
 
ulint m_sort_multi_factor
 During the sort phase, increment the counter once per this many pages processed. More...
 
ulint m_n_recs_processed
 Number of records processed during sort & insert phases. More...
 
ulint m_n_flush_pages
 Number of pages to flush. More...
 
enum ut_stage_alter_t:: { ... }  m_cur_phase
 Current phase. More...
 

Detailed Description

Class used to report ALTER TABLE progress via performance_schema.

The only user of this class is the ALTER TABLE code and it calls the methods in the following order constructor begin_phase_read_pk() multiple times: n_pk_recs_inc() // once per record read inc() // once per page read end_phase_read_pk() if any new indexes are being added, for each one: begin_phase_sort() multiple times: inc() // once per record sorted begin_phase_insert() multiple times: inc() // once per record inserted being_phase_log_index() multiple times: inc() // once per log-block applied begin_phase_flush() multiple times: inc() // once per page flushed begin_phase_log_table() multiple times: inc() // once per log-block applied begin_phase_end() destructor

This class knows the specifics of each phase and tries to increment the progress in an even manner across the entire ALTER TABLE lifetime.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

Current phase.

Enumerator
NOT_STARTED 
READ_PK 
SORT 
INSERT 
FLUSH 
LOG_INDEX 
LOG_TABLE 
END 

Constructor & Destructor Documentation

◆ ut_stage_alter_t()

ut_stage_alter_t::ut_stage_alter_t ( const dict_index_t pk)
inlineexplicit

Constructor.

Parameters
[in]pkprimary key of the old table

◆ ~ut_stage_alter_t()

ut_stage_alter_t::~ut_stage_alter_t ( )
inline

Destructor.

Member Function Documentation

◆ begin_phase_end()

void ut_stage_alter_t::begin_phase_end ( )
inline

Flag the beginning of the end phase.

◆ begin_phase_flush()

void ut_stage_alter_t::begin_phase_flush ( ulint  n_flush_pages)
inline

Flag the beginning of the flush phase.

Parameters
[in]n_flush_pagesthis many pages are going to be flushed

◆ begin_phase_insert()

void ut_stage_alter_t::begin_phase_insert ( )
inline

Flag the beginning of the insert phase.

◆ begin_phase_log_index()

void ut_stage_alter_t::begin_phase_log_index ( )
inline

Flag the beginning of the log index phase.

◆ begin_phase_log_table()

void ut_stage_alter_t::begin_phase_log_table ( )
inline

Flag the beginning of the log table phase.

◆ begin_phase_read_pk()

void ut_stage_alter_t::begin_phase_read_pk ( ulint  n_sort_indexes)
inline

Flag an ALTER TABLE start (read primary key phase).

Parameters
[in]n_sort_indexesnumber of indexes that will be sorted during ALTER TABLE, used for estimating the total work to be done

◆ begin_phase_sort()

void ut_stage_alter_t::begin_phase_sort ( double  sort_multi_factor)
inline

Flag the beginning of the sort phase.

Parameters
[in]sort_multi_factorsince merge sort processes one page more than once we only update the estimate once per this many pages processed.

◆ change_phase()

void ut_stage_alter_t::change_phase ( const PSI_stage_info new_stage)
inlineprivate

Change the current phase.

Parameters
[in]new_stagepointer to the new stage to change to

◆ end_phase_read_pk()

void ut_stage_alter_t::end_phase_read_pk ( )
inline

Flag the end of reading of the primary key.

Here we know the exact number of pages and records and calculate the number of records per page and refresh the estimate.

◆ inc()

void ut_stage_alter_t::inc ( ulint  inc_val = 1)
inline

Flag either one record or one page processed, depending on the current phase.

Parameters
[in]inc_valflag this many units processed at once

◆ n_pk_recs_inc()

void ut_stage_alter_t::n_pk_recs_inc ( )
inline

Increment the number of records in PK (table) with 1.

This is used to get more accurate estimate about the number of records per page which is needed because some phases work on per-page basis while some work on per-record basis and we want to get the progress as even as possible.

◆ reestimate()

void ut_stage_alter_t::reestimate ( )
inlineprivate

Update the estimate of total work to be done.

Member Data Documentation

◆ m_cur_phase

enum { ... } ut_stage_alter_t::m_cur_phase

Current phase.

◆ m_n_flush_pages

ulint ut_stage_alter_t::m_n_flush_pages
private

Number of pages to flush.

◆ m_n_pk_pages

ulint ut_stage_alter_t::m_n_pk_pages
private

Number of leaf pages in the primary key.

◆ m_n_pk_recs

ulint ut_stage_alter_t::m_n_pk_recs
private

Number of records in the primary key (table), including delete marked records.

◆ m_n_recs_per_page

double ut_stage_alter_t::m_n_recs_per_page
private

Estimated number of records per page in the primary key.

◆ m_n_recs_processed

ulint ut_stage_alter_t::m_n_recs_processed
private

Number of records processed during sort & insert phases.

We need to increment the counter only once page, or once per recs-per-page records.

◆ m_n_sort_indexes

ulint ut_stage_alter_t::m_n_sort_indexes
private

Number of indexes that are being added.

◆ m_pk

const dict_index_t* ut_stage_alter_t::m_pk
private

Old table PK.

Used for calculating the estimate.

◆ m_progress

PSI_stage_progress* ut_stage_alter_t::m_progress
private

Performance schema accounting object.

◆ m_sort_multi_factor

ulint ut_stage_alter_t::m_sort_multi_factor
private

During the sort phase, increment the counter once per this many pages processed.

This is because sort processes one page more than once.


The documentation for this class was generated from the following file: