Below is the list of changes that have just been committed into a local
5.0 repository of tnurnberg. When tnurnberg 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, 2007-11-10 18:29:13+01:00, tnurnberg@stripped +2 -0
Bug#31700: thd->examined_row_count not incremented for 'const' type queries
UNIQUE (eq-ref) lookups result in table being considered as a "constant" table.
Queries that consist of only constant tables are processed in do_select() in a
special way that doesn't invoke evaluate_join_record(), and therefore doesn't
increase the counters join->examined_rows and join->thd->row_count.
The patch increases these counters in this special case.
NOTICE:
This behavior seems to contradict what the documentation says in Sect. 5.11.4:
"Queries handled by the query cache are not added to the slow query log, nor
are queries that would not benefit from the presence of an index because the
table has zero rows or one row."
No test case in 5.0 as issue shows only in slow query log, and other counters
can give subtly different values (with regard to counting in create_sort_index(),
synthetic rows in ROLLUP, etc.).
sql/sql_class.h@stripped, 2007-11-10 18:29:11+01:00, tnurnberg@stripped +19 -4
add documentation for some variables
sql/sql_select.cc@stripped, 2007-11-10 18:29:11+01:00, tnurnberg@stripped +9 -0
Don't forget const tables when counting read records!
diff -Nrup a/sql/sql_class.h b/sql/sql_class.h
--- a/sql/sql_class.h 2007-10-23 13:15:24 +02:00
+++ b/sql/sql_class.h 2007-11-10 18:29:11 +01:00
@@ -1368,9 +1368,20 @@ public:
ulonglong limit_found_rows;
ulonglong options; /* Bitmap of states */
- longlong row_count_func; /* For the ROW_COUNT() function */
- ha_rows cuted_fields,
- sent_row_count, examined_row_count;
+ longlong row_count_func; /* For the ROW_COUNT() function */
+ ha_rows cuted_fields;
+
+ /*
+ number of rows we actually sent to the client, including "synthetic"
+ rows in ROLLUP etc.
+ */
+ ha_rows sent_row_count;
+
+ /*
+ number of rows we read, sent or not, including in create_sort_index()
+ */
+ ha_rows examined_row_count;
+
/*
The set of those tables whose fields are referenced in all subqueries
of the query.
@@ -1403,7 +1414,11 @@ public:
/* Statement id is thread-wide. This counter is used to generate ids */
ulong statement_id_counter;
ulong rand_saved_seed1, rand_saved_seed2;
- ulong row_count; // Row counter, mainly for errors and warnings
+ /*
+ Row counter, mainly for errors and warnings. Not increased in
+ create_sort_index(); may differ from examined_row_count.
+ */
+ ulong row_count;
long dbug_thread_id;
pthread_t real_id;
uint tmp_table, global_read_lock;
diff -Nrup a/sql/sql_select.cc b/sql/sql_select.cc
--- a/sql/sql_select.cc 2007-10-23 15:48:56 +02:00
+++ b/sql/sql_select.cc 2007-11-10 18:29:11 +01:00
@@ -10339,6 +10339,15 @@ do_select(JOIN *join,List<Item> *fields,
error= (*end_select)(join,join_tab,0);
if (error == NESTED_LOOP_OK || error == NESTED_LOOP_QUERY_LIMIT)
error= (*end_select)(join,join_tab,1);
+
+ /*
+ If we don't go through evaluate_join_record(), do the counting
+ here. join->send_records is increased on success in end_send(),
+ so we don't touch it here.
+ */
+ join->examined_rows++;
+ join->thd->row_count++;
+ DBUG_ASSERT(join->examined_rows <= 1);
}
else if (join->send_row_on_empty_set())
{
| Thread |
|---|
| • bk commit into 5.0 tree (tnurnberg:1.2557) BUG#31700 | Tatjana A Nuernberg | 10 Nov |