diff --git a/sql/handler.cc b/sql/handler.cc index 64041ab330a..fbadf12f0ef 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 *backup; + h2->table->in_use->enter_stage(&stage_mrr_fetch_primary_key, backup, __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 */ @@ -6781,11 +6784,13 @@ int DsMrr_impl::dsmrr_fill_buffer() { uint elem_size = h->ref_length + (int)is_mrr_assoc * sizeof(void *); assert((rowids_buf_cur - rowids_buf) % elem_size == 0); + h2->table->in_use->enter_stage(&stage_mrr_sort_primary_key, NULL, __func__, __FILE__, __LINE__); varlen_sort( rowids_buf, rowids_buf_cur, elem_size, [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(backup, NULL, __func__, __FILE__, __LINE__); return 0; } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 780515cca7f..6c8ad512c78 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, "Fetching Primary Key", 0, PSI_DOCUMENT_ME}; +PSI_stage_info stage_mrr_sort_primary_key= { 0, "Sortting 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).