mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-3953 Add columns for ROWS_EXAMINED, ROWS_SENT, and ROWS_READ to I_S and processlist
MDEV-32441 SENT_ROWS shows random wrong values when stored function is selected. MDEV-32281 EXAMINED_ROWS is not populated in information_schema.processlist upon SELECT. Added ROWS_SENT to information_schema.processlist This is to have the same information as Percona server (SENT_ROWS) To ensure that information_schema.processlist has correct values for sent_rows and examined_rows I introduced two new variables to hold the total counts so far. This was needed as stored functions and stored procedures will reset the normal counters to be able to count rows for each statement individually for slow query log. Other things: - Selects with functions shows in processlist the total examined_rows and sent_rows by the main statement and all functions. - Stored procedures shows in processlist examined_rows and sent_rows per stored procedure statement. - Fixed some double accounting for sent_rows and examined_rows. - HANDLER operations now also supports send_rows and examined_rows. - Display sizes for MEMORY_USED, MAX_MEMORY_USED, EXAMINED_ROWS and QUERY_ID in information_schema.processlist changed to 10 characters. - EXAMINED_ROWS and SENT_ROWS changed to bigint. - INSERT RETURNING and DELETE RETURNING now updates SENT_ROWS. - As thd is always up to date with examined_rows, we do not need to handle examined row counting for unions or filesort. - I renamed SORT_INFO::examined_rows to m_examined_rows to ensure that we don't get bugs in merges that tries to use examined_rows. - Removed calls of type "thd->set_examined_row_count(0)" as they are not needed anymore. - Removed JOIN::join_examined_rows - Removed not used functions: THD::set_examined_row_count() - Made inline some functions that where called for each row.
This commit is contained in:
@@ -2033,6 +2033,7 @@ public:
|
||||
ulonglong tmp_tables_size;
|
||||
ulonglong client_capabilities;
|
||||
ulonglong cuted_fields, sent_row_count, examined_row_count;
|
||||
ulonglong sent_row_count_for_statement, examined_row_count_for_statement;
|
||||
ulonglong affected_rows;
|
||||
ulonglong bytes_sent_old;
|
||||
ha_handler_stats handler_stats;
|
||||
@@ -2043,6 +2044,7 @@ public:
|
||||
uint in_sub_stmt; /* 0, SUB_STMT_TRIGGER or SUB_STMT_FUNCTION */
|
||||
bool enable_slow_log;
|
||||
bool last_insert_id_used;
|
||||
bool in_stored_procedure;
|
||||
enum enum_check_fields count_cuted_fields;
|
||||
};
|
||||
|
||||
@@ -3568,12 +3570,13 @@ public:
|
||||
|
||||
ha_rows cuted_fields;
|
||||
|
||||
private:
|
||||
/*
|
||||
number of rows we actually sent to the client, including "synthetic"
|
||||
rows in ROLLUP etc.
|
||||
*/
|
||||
ha_rows m_sent_row_count;
|
||||
/* Number of rows for the total statement */
|
||||
ha_rows sent_row_count_for_statement;
|
||||
|
||||
/**
|
||||
Number of rows read and/or evaluated for a statement. Used for
|
||||
@@ -3586,8 +3589,9 @@ private:
|
||||
filesort() before reading it for e.g. update.
|
||||
*/
|
||||
ha_rows m_examined_row_count;
|
||||
/* Number of rows for the top level query */
|
||||
ha_rows examined_row_count_for_statement;
|
||||
|
||||
public:
|
||||
ha_rows get_sent_row_count() const
|
||||
{ return m_sent_row_count; }
|
||||
|
||||
@@ -3598,10 +3602,27 @@ public:
|
||||
{ return affected_rows; }
|
||||
|
||||
void set_sent_row_count(ha_rows count);
|
||||
void set_examined_row_count(ha_rows count);
|
||||
|
||||
void inc_sent_row_count(ha_rows count);
|
||||
void inc_examined_row_count(ha_rows count);
|
||||
inline void inc_sent_row_count(ha_rows count)
|
||||
{
|
||||
m_sent_row_count+= count;
|
||||
sent_row_count_for_statement+= count;
|
||||
MYSQL_SET_STATEMENT_ROWS_SENT(m_statement_psi, m_sent_row_count);
|
||||
}
|
||||
inline void inc_examined_row_count_fast()
|
||||
{
|
||||
m_examined_row_count++;
|
||||
examined_row_count_for_statement++;
|
||||
}
|
||||
inline void inc_examined_row_count()
|
||||
{
|
||||
inc_examined_row_count_fast();
|
||||
DBUG_EXECUTE_IF("debug_huge_number_of_examined_rows",
|
||||
m_examined_row_count= (ULONGLONG_MAX - 1000000););
|
||||
MYSQL_SET_STATEMENT_ROWS_EXAMINED(m_statement_psi, m_examined_row_count);
|
||||
}
|
||||
|
||||
void ps_report_examined_row_count();
|
||||
|
||||
void inc_status_created_tmp_disk_tables();
|
||||
void inc_status_created_tmp_files();
|
||||
@@ -4728,7 +4749,7 @@ public:
|
||||
void reset_sub_statement_state(Sub_statement_state *backup, uint new_state);
|
||||
void restore_sub_statement_state(Sub_statement_state *backup);
|
||||
void store_slow_query_state(Sub_statement_state *backup);
|
||||
void reset_slow_query_state();
|
||||
void reset_slow_query_state(Sub_statement_state *backup);
|
||||
void add_slow_query_state(Sub_statement_state *backup);
|
||||
void set_n_backup_active_arena(Query_arena *set, Query_arena *backup);
|
||||
void restore_active_arena(Query_arena *set, Query_arena *backup);
|
||||
@@ -5784,6 +5805,15 @@ public:
|
||||
return false;
|
||||
return !is_set_timestamp_forbidden(this);
|
||||
}
|
||||
/*
|
||||
Return true if we are in stored procedure, not in a function or
|
||||
trigger.
|
||||
*/
|
||||
bool in_stored_procedure()
|
||||
{
|
||||
return (lex->sphead != 0 &&
|
||||
!(in_sub_stmt & (SUB_STMT_FUNCTION | SUB_STMT_TRIGGER)));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user