Below is the list of changes that have just been committed into a local
4.1 repository of istruewing. When istruewing does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2006-10-11 09:52:53+02:00, istruewing@stripped +1 -0
Bug#12240 - Rows Examined in Slow Log showing incorrect number?
Examined rows are counted for every join part. The per-join-part
counter was incremented over all iterations. The result variable
was replaced at the end of every iteration. The final result was
the number of examined rows by the join part that ended its
execution as the last one. The numbers of other join parts was
lost.
Now we reset the per-join-part counter before every iteration and
add it to the result variable at the end of the iteration. That
way we get the sum of all iterations of all join parts.
sql/sql_select.cc@stripped, 2006-10-11 09:52:50+02:00, istruewing@stripped +18 -6
Bug#12240 - Rows Examined in Slow Log showing incorrect number?
Fixed reseting and accumulation of examined rows counts.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: istruewing
# Host: chilla.local
# Root: /home/mydev/mysql-4.1-bug12240
--- 1.459/sql/sql_select.cc 2006-10-11 09:52:57 +02:00
+++ 1.460/sql/sql_select.cc 2006-10-11 09:52:57 +02:00
@@ -1171,12 +1171,13 @@ JOIN::exec()
thd->examined_row_count= 0;
DBUG_VOID_RETURN;
}
- /*
- don't reset the found rows count if there're no tables
- as FOUND_ROWS() may be called.
- */
+ /*
+ Don't reset the found rows count if there're no tables as
+ FOUND_ROWS() may be called. Never reset the examined row count here.
+ It must be accumulated from all join iterations of all join parts.
+ */
if (tables)
- thd->limit_found_rows= thd->examined_row_count= 0;
+ thd->limit_found_rows= 0;
if (zero_result_cause)
{
@@ -1224,6 +1225,12 @@ JOIN::exec()
List<Item> *curr_all_fields= &all_fields;
List<Item> *curr_fields_list= &fields_list;
TABLE *curr_tmp_table= 0;
+ /*
+ Initialize examined rows here because the values from all join parts
+ must be accumulated in examined_row_count. Hence every join
+ iteration must count from zero.
+ */
+ curr_join->examined_rows= 0;
/* Create a tmp table if distinct or if the sort is too complicated */
if (need_tmp)
@@ -1572,7 +1579,10 @@ JOIN::exec()
error= thd->net.report_error ? -1 :
do_select(curr_join, curr_fields_list, NULL, procedure);
thd->limit_found_rows= curr_join->send_records;
- thd->examined_row_count= curr_join->examined_rows;
+ /* Accumulate the counts from all join iterations of all join parts. */
+ thd->examined_row_count+= curr_join->examined_rows;
+ DBUG_PRINT("counts", ("thd->examined_row_count: %lu",
+ (ulong) thd->examined_row_count));
DBUG_VOID_RETURN;
}
@@ -6179,6 +6189,8 @@ sub_select(JOIN *join,JOIN_TAB *join_tab
return -2; /* purecov: inspected */
}
join->examined_rows++;
+ DBUG_PRINT("counts", ("join->examined_rows++: %lu",
+ (ulong) join->examined_rows));
join->thd->row_count++;
if (!on_expr || on_expr->val_int())
{
| Thread |
|---|
| • bk commit into 4.1 tree (istruewing:1.2560) BUG#12240 | ingo | 11 Oct |