From 8707673a83b9663723613ab494fc746638412cc1 Mon Sep 17 00:00:00 2001 From: Nikita Malyavin Date: Tue, 9 Jan 2024 21:54:57 +0100 Subject: [PATCH] counters --- sql/handler.cc | 15 +++++++++++---- sql/mysqld.cc | 1 + sql/sql_class.h | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index eb64af49dd485..2293cfa22392d 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -7299,7 +7299,7 @@ int handler::binlog_log_row(const uchar *before_record, const uchar *after_record, Log_func *log_func) { - DBUG_ENTER("handler::binlog_log_row"); +// DBUG_ENTER("handler::binlog_log_row"); int error = 0; if (row_logging) @@ -7312,7 +7312,7 @@ int handler::binlog_log_row(const uchar *before_record, log_func); #endif // HAVE_REPLICATION - DBUG_RETURN(error); + return error; } @@ -7831,7 +7831,6 @@ int handler::prepare_for_insert(bool do_create) return 0; } - int handler::ha_write_row(const uchar *buf) { int error; @@ -7883,7 +7882,7 @@ int handler::ha_write_row(const uchar *buf) DBUG_RETURN(error); } - +#include int handler::ha_update_row(const uchar *old_data, const uchar *new_data) { int error; @@ -7916,6 +7915,9 @@ int handler::ha_update_row(const uchar *old_data, const uchar *new_data) MYSQL_UPDATE_ROW_DONE(error); if (likely(!error)) { + bool count_time= false; + DBUG_EXECUTE_IF("binlog_log_row_time", count_time=true;); + auto now= std::chrono::high_resolution_clock::now(); rows_changed++; Log_func *log_func= Update_rows_log_event::binlog_row_logging_function; error= binlog_log_row(old_data, new_data, log_func); @@ -7940,6 +7942,11 @@ int handler::ha_update_row(const uchar *old_data, const uchar *new_data) error= wsrep_after_row(thd); } #endif /* WITH_WSREP */ + if (likely(count_time)) + table->in_use->status_var.dbug_time_spent+= + std::chrono::duration_cast( + std::chrono::high_resolution_clock::now() - now).count(); + } return error; } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 56ca8cfc37057..6a33008bf1c40 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -7473,6 +7473,7 @@ SHOW_VAR status_vars[]= { {"Created_tmp_tables", (char*) offsetof(STATUS_VAR, created_tmp_tables_), SHOW_LONG_STATUS}, #ifndef DBUG_OFF SHOW_FUNC_ENTRY("Debug", &debug_status_func), + {"Dbug_time_spent", (char*) offsetof(STATUS_VAR, dbug_time_spent), SHOW_LONG_STATUS}, #endif {"Delayed_errors", (char*) &delayed_insert_errors, SHOW_LONG}, {"Delayed_insert_threads", (char*) &delayed_insert_threads, SHOW_LONG_NOFLUSH}, diff --git a/sql/sql_class.h b/sql/sql_class.h index 216b4a9a40444..2eeb32d8c9644 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1017,6 +1017,7 @@ typedef struct system_status_var */ ulong skip_metadata_count; + ulonglong dbug_time_spent; /* Number of statements sent from the client */