Skip to content

Commit

Permalink
MDEV-18478 ANALYZE for statement should show selectivity of ICP, part#3
Browse files Browse the repository at this point in the history
Fix the previous patch:
- Only enable handler_stats if thd->should_collect_handler_stats()==true.
- Make handler_index_cond_check() work when handler_stats are not enabled.
  • Loading branch information
spetrunia committed Apr 23, 2024
1 parent 86e727b commit 486d42d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 4 additions & 3 deletions sql/handler.cc
Expand Up @@ -6995,7 +6995,6 @@ 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))
Expand All @@ -7009,13 +7008,15 @@ 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->handler_stats->icp_attempts++;
if (unlikely(h->handler_stats))
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->handler_stats->icp_match++;
if (unlikely(h->handler_stats))
h->handler_stats->icp_match++;
}
return res;
}
Expand Down
6 changes: 5 additions & 1 deletion sql/table.cc
Expand Up @@ -5871,7 +5871,11 @@ void TABLE::init(THD *thd, TABLE_LIST *tl)
(*f_ptr)->cond_selectivity= 1.0;
}

file->ha_handler_stats_reset();
/* enable and clear or disable engine query statistics */
if (thd->should_collect_handler_stats())
file->ha_handler_stats_reset();
else
file->ha_handler_stats_disable();

notnull_cond= 0;
DBUG_ASSERT(!file->keyread_enabled());
Expand Down

0 comments on commit 486d42d

Please sign in to comment.