Skip to content

Commit

Permalink
counters
Browse files Browse the repository at this point in the history
  • Loading branch information
FooBarrior committed Jan 9, 2024
1 parent 593c4ce commit 8707673
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
15 changes: 11 additions & 4 deletions sql/handler.cc
Expand Up @@ -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)
Expand All @@ -7312,7 +7312,7 @@ int handler::binlog_log_row(const uchar *before_record,
log_func);
#endif // HAVE_REPLICATION

DBUG_RETURN(error);
return error;
}


Expand Down Expand Up @@ -7831,7 +7831,6 @@ int handler::prepare_for_insert(bool do_create)
return 0;
}


int handler::ha_write_row(const uchar *buf)
{
int error;
Expand Down Expand Up @@ -7883,7 +7882,7 @@ int handler::ha_write_row(const uchar *buf)
DBUG_RETURN(error);
}


#include <chrono>
int handler::ha_update_row(const uchar *old_data, const uchar *new_data)
{
int error;
Expand Down Expand Up @@ -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);
Expand All @@ -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::nanoseconds>(
std::chrono::high_resolution_clock::now() - now).count();

}
return error;
}
Expand Down
1 change: 1 addition & 0 deletions sql/mysqld.cc
Expand Up @@ -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},
Expand Down
1 change: 1 addition & 0 deletions sql/sql_class.h
Expand Up @@ -1017,6 +1017,7 @@ typedef struct system_status_var
*/
ulong skip_metadata_count;

ulonglong dbug_time_spent;
/*
Number of statements sent from the client
*/
Expand Down

0 comments on commit 8707673

Please sign in to comment.