Commit a11a1019 authored by Dave Gosselin's avatar Dave Gosselin Committed by Sergei Petrunia

accrue statistics to correct handler

parent 0940a969
......@@ -6995,6 +6995,7 @@ extern "C" check_result_t handler_index_cond_check(void* h_arg)
check_result_t res;
DEBUG_SYNC(thd, "handler_index_cond_check");
DBUG_ASSERT(h->handler_stats);
enum thd_kill_levels killed= thd_kill_level(thd);
if (unlikely(killed != THD_IS_NOT_KILLED))
......@@ -7008,13 +7009,13 @@ extern "C" check_result_t handler_index_cond_check(void* h_arg)
if (unlikely(h->end_range) && h->compare_key2(h->end_range) > 0)
return CHECK_OUT_OF_RANGE;
h->increment_statistics(&SSV::ha_icp_attempts);
h->active_handler_stats.icp_attempts++;
h->handler_stats->icp_attempts++;
res= CHECK_NEG;
if (h->pushed_idx_cond->val_int())
{
res= CHECK_POS;
h->fast_increment_statistics(&SSV::ha_icp_match);
h->active_handler_stats.icp_match++;
h->handler_stats->icp_match++;
}
return res;
}
......
......@@ -3211,7 +3211,13 @@ class handler :public Sql_alloc
ha_rows estimation_rows_to_insert;
handler *lookup_handler;
/* Statistics for the query. Updated if handler_stats.in_use is set */
/*
Statistics for the query. Prefer to use the handler_stats pointer
below rather than this object directly as the clone() method will
modify how stats are accounted by adjusting the handler_stats
pointer. Referring to active_handler_stats directly will yield
surprising and possibly incorrect results.
*/
ha_handler_stats active_handler_stats;
void set_handler_stats();
public:
......
......@@ -1938,13 +1938,13 @@ static void trace_engine_stats(handler *file, Json_writer *writer)
static void print_r_icp_filtered(handler *file, Json_writer *writer)
{
if (file && file->handler_stats && file->pushed_idx_cond)
{
ha_handler_stats *hs= file->handler_stats;
double r_icp_filtered = hs->icp_attempts ?
(double)(hs->icp_match) / (double)(hs->icp_attempts) : 1.0;
writer->add_member("r_icp_filtered").add_double(r_icp_filtered * 100);
}
if (!file || !file->handler_stats || !file->pushed_idx_cond)
return;
ha_handler_stats *hs= file->handler_stats;
double r_icp_filtered = hs->icp_attempts ?
(double)(hs->icp_match) / (double)(hs->icp_attempts) : 0.0;
writer->add_member("r_icp_filtered").add_double(r_icp_filtered * 100);
}
void Explain_table_access::print_explain_json(Explain_query *query,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment