diff --git a/sql/handler.cc b/sql/handler.cc index 64041ab330a..d1abe93b13a 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -6758,6 +6758,9 @@ int DsMrr_impl::dsmrr_fill_buffer() { Do not use ha_multi_range_read_next() as it would call the engine's overridden multi_range_read_next() but the default implementation is wanted. */ + PSI_stage_info *stage_save; + h2->table->in_use->enter_stage(&stage_mrr_fetch_primary_key, stage_save, __func__, __FILE__, __LINE__); + while ((rowids_buf_cur < rowids_buf_end) && !(res = h2->handler::multi_range_read_next(&range_info))) { /* Put rowid, or {rowid, range_id} pair into the buffer */ @@ -6778,6 +6781,7 @@ int DsMrr_impl::dsmrr_fill_buffer() { dsmrr_eof = (res == HA_ERR_END_OF_FILE); /* Sort the buffer contents by rowid */ + h2->table->in_use->enter_stage(&stage_mrr_sort_primary_key, NULL, __func__, __FILE__, __LINE__); uint elem_size = h->ref_length + (int)is_mrr_assoc * sizeof(void *); assert((rowids_buf_cur - rowids_buf) % elem_size == 0); @@ -6786,6 +6790,7 @@ int DsMrr_impl::dsmrr_fill_buffer() { [this](const uchar *a, const uchar *b) { return h->cmp_ref(a, b) < 0; }); rowids_buf_last = rowids_buf_cur; rowids_buf_cur = rowids_buf; + h2->table->in_use->enter_stage(stage_save, NULL, __func__, __FILE__, __LINE__); return 0; } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 780515cca7f..278b911075f 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -12237,6 +12237,8 @@ PSI_stage_info stage_rpl_failover_updating_source_member_details= { 0, "Updating PSI_stage_info stage_rpl_failover_wait_before_next_fetch= { 0, "Wait before trying to fetch next membership changes from source", 0, PSI_DOCUMENT_ME}; PSI_stage_info stage_communication_delegation= { 0, "Connection delegated to Group Replication", 0, PSI_DOCUMENT_ME}; PSI_stage_info stage_wait_on_commit_ticket= { 0, "Waiting for Binlog Group Commit ticket", 0, PSI_DOCUMENT_ME}; +PSI_stage_info stage_mrr_fetch_primary_key= { 0, "Mrr Fetching Primary Key", 0, PSI_DOCUMENT_ME}; +PSI_stage_info stage_mrr_sort_primary_key= { 0, "Mrr Sorting Primary Key", 0, PSI_DOCUMENT_ME}; /* clang-format on */ extern PSI_stage_info stage_waiting_for_disk_space; diff --git a/sql/mysqld.h b/sql/mysqld.h index ada25f4dc9d..2b770d26ebe 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -652,6 +652,9 @@ extern PSI_stage_info stage_rpl_failover_updating_source_member_details; extern PSI_stage_info stage_rpl_failover_wait_before_next_fetch; extern PSI_stage_info stage_communication_delegation; extern PSI_stage_info stage_wait_on_commit_ticket; +extern PSI_stage_info stage_mrr_fetch_primary_key; +extern PSI_stage_info stage_mrr_sort_primary_key; + #ifdef HAVE_PSI_STATEMENT_INTERFACE /** Statement instrumentation keys (sql).