diff options
| author | Staale Smedseng <staale.smedseng@sun.com> | 2010-05-12 13:19:12 +0200 |
|---|---|---|
| committer | Staale Smedseng <staale.smedseng@sun.com> | 2010-05-12 13:19:12 +0200 |
| commit | 330864fcda68a90995194576d4ad1ebec1b955e1 (patch) | |
| tree | 4ef21dd129bfee355e60f5dc81af3bbf22b119f1 /sql | |
| parent | 29c8c152b26398ce7ad84a9794f229b10ad9d410 (diff) | |
| download | mariadb-git-330864fcda68a90995194576d4ad1ebec1b955e1.tar.gz | |
Bug #49756 Rows_examined is always 0 in the slow query log for
update statements
Only SELECT statements report any examined rows in the slow
log. Slow UPDATE, DELETE and INSERT statements report 0 rows
examined, unless the statement has a condition including a
SELECT substatement.
This patch adds counting of examined rows for the UPDATE and
DELETE statements. An INSERT ... VALUES statement will still
not report any rows as examined.
sql/sql_class.h:
Added more docs for THD::examined_row_count.
sql/sql_delete.cc:
Add incrementing thd->examined_row_count.
sql/sql_update.cc:
Add incrementing thd->examined_row_count.
Diffstat (limited to 'sql')
| -rw-r--r-- | sql/sql_class.h | 11 | ||||
| -rw-r--r-- | sql/sql_delete.cc | 2 | ||||
| -rw-r--r-- | sql/sql_update.cc | 3 |
3 files changed, 14 insertions, 2 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h index 4d0552c5b9d..bd3cf8bc401 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1716,8 +1716,15 @@ public: */ ha_rows sent_row_count; - /* - number of rows we read, sent or not, including in create_sort_index() + /** + Number of rows read and/or evaluated for a statement. Used for + slow log reporting. + + An examined row is defined as a row that is read and/or evaluated + according to a statement condition, including in + create_sort_index(). Rows may be counted more than once, e.g., a + statement including ORDER BY could possibly evaluate the row in + filesort() before reading it for e.g. update. */ ha_rows examined_row_count; diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 7e91a37257b..cc29b6f1b6b 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -248,6 +248,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, free_underlaid_joins(thd, &thd->lex->select_lex); DBUG_RETURN(TRUE); } + thd->examined_row_count+= examined_rows; /* Filesort has already found and selected the rows we want to delete, so we don't need the where clause @@ -304,6 +305,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, while (!(error=info.read_record(&info)) && !thd->killed && ! thd->is_error()) { + thd->examined_row_count++; // thd->is_error() is tested to disallow delete row on error if (!(select && select->skip_record())&& ! thd->is_error() ) { diff --git a/sql/sql_update.cc b/sql/sql_update.cc index d8141deba63..69f3a29e923 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -425,6 +425,7 @@ int mysql_update(THD *thd, { goto err; } + thd->examined_row_count+= examined_rows; /* Filesort has already found and selected the rows we want to update, so we don't need the where clause @@ -471,6 +472,7 @@ int mysql_update(THD *thd, while (!(error=info.read_record(&info)) && !thd->killed) { + thd->examined_row_count++; if (!(select && select->skip_record())) { if (table->file->was_semi_consistent_read()) @@ -577,6 +579,7 @@ int mysql_update(THD *thd, while (!(error=info.read_record(&info)) && !thd->killed) { + thd->examined_row_count++; if (!(select && select->skip_record())) { if (table->file->was_semi_consistent_read()) |
