MySQL 8.0.39
Source Code Documentation
|
Class used to report ALTER TABLE progress via performance_schema. More...
#include <ut0stage.h>
Public Member Functions | |
Alter_stage (const dict_index_t *pk) noexcept | |
Constructor. More... | |
Alter_stage (const Alter_stage &rhs) noexcept | |
Copy constructor. More... | |
~Alter_stage () | |
Destructor. More... | |
void | begin_phase_read_pk (size_t 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 | n_pk_recs_inc (uint64_t n) |
See simple increment version above. More... | |
void | inc (uint64_t inc_val) |
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 (page_no_t 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... | |
void | aggregate (const Alter_stages &alter_stages) noexcept |
Aggregate the results of the build from the sub builds. 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... | |
using | Counter = std::pair< uint64_t, uint64_t > |
using | Progress = std::pair< PSI_stage_progress *, Counter > |
using | Stage = std::pair< const PSI_stage_info *, Progress > |
using | Stages = std::vector< Stage, ut::allocator< Stage > > |
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 | |
Stage | m_stage {} |
Progress counters for the various stages. More... | |
Stages | m_stages {} |
Collection of previous stages. More... | |
const dict_index_t * | m_pk {} |
Old table PK. More... | |
std::atomic< uint64_t > | m_n_pk_recs {} |
Number of records in the primary key (table), including delete marked records. More... | |
page_no_t | 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... | |
size_t | m_n_sort_indexes {} |
Number of indexes that are being added. More... | |
uint64_t | m_sort_multi_factor {} |
During the sort phase, increment the counter once per this many pages processed. More... | |
uint64_t | m_n_inserted {} |
Number of records processed during sort & insert phases. More... | |
page_no_t | m_n_flush_pages {} |
Number of pages to flush. More... | |
enum Alter_stage:: { ... } | NOT_STARTED |
Current phase. More... | |
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.
|
private |
|
private |
|
private |
|
private |
|
private |
Current phase.
|
inlineexplicitnoexcept |
Constructor.
[in] | pk | primary key of the old table |
|
inlineexplicitnoexcept |
Copy constructor.
"Inherits" the current state of rhs.
[in] | rhs | Instance to copy current state from. |
|
inline |
Destructor.
|
inlinenoexcept |
Aggregate the results of the build from the sub builds.
[in] | alter_stages | Sub stages to aggregate. |
|
inline |
Flag the beginning of the end phase.
|
inline |
Flag the beginning of the flush phase.
[in] | n_flush_pages | this many pages are going to be flushed |
|
inline |
Flag the beginning of the insert phase.
|
inline |
Flag the beginning of the log index phase.
|
inline |
Flag the beginning of the log table phase.
|
inline |
Flag an ALTER TABLE start (read primary key phase).
[in] | n_sort_indexes | number of indexes that will be sorted during ALTER TABLE, used for estimating the total work to be done |
|
inline |
Flag the beginning of the sort phase.
[in] | sort_multi_factor | since merge sort processes one page more than once we only update the estimate once per this many pages processed. |
|
inlineprivate |
Change the current phase.
[in] | new_stage | pointer to the new stage to change to |
|
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.
|
inline |
Flag either one record or one page processed, depending on the current phase.
[in] | inc_val | flag this many units processed at once |
|
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.
|
inline |
See simple increment version above.
[in] | n | Number fo records read so far. |
|
inlineprivate |
Update the estimate of total work to be done.
|
private |
Number of pages to flush.
|
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.
|
private |
Number of leaf pages in the primary key.
|
private |
Number of records in the primary key (table), including delete marked records.
|
private |
Estimated number of records per page in the primary key.
|
private |
Number of indexes that are being added.
|
private |
Old table PK.
Used for calculating the estimate.
|
private |
During the sort phase, increment the counter once per this many pages processed.
This is because sort processes one page more than once.
|
private |
Progress counters for the various stages.
|
private |
Collection of previous stages.
enum { ... } Alter_stage::NOT_STARTED |
Current phase.