diff options
author | tnurnberg@mysql.com/white.intern.koehntopp.de <> | 2007-11-10 18:29:13 +0100 |
---|---|---|
committer | tnurnberg@mysql.com/white.intern.koehntopp.de <> | 2007-11-10 18:29:13 +0100 |
commit | 8a5e621ff2c902762f60ee09eb30a58d2585950c (patch) | |
tree | 28a89079b146a8d9d134c29fe4eda9a517bd8bc2 /sql/sql_select.cc | |
parent | 6b92ec4acbf78892bc4880913a762db0189ce20f (diff) | |
download | mariadb-git-8a5e621ff2c902762f60ee09eb30a58d2585950c.tar.gz |
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.).
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 7af39071561..d6aae35205c 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -10339,6 +10339,15 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure) 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()) { |