1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-18478 ANALYZE for statement should show selectivity of ICP, part#1

(Based on the original patch by Jason Cu)

Part #1:
- Add ha_handler_stats::{icp_attempts,icp_match}, make
  handler_index_cond_check() increment them.
- ANALYZE FORMAT=JSON now prints r_icp_filtered based on these counters.
This commit is contained in:
Sergei Petrunia
2023-12-11 16:06:59 +03:00
parent 3f9182126c
commit e87d1e391b
9 changed files with 556 additions and 1 deletions

View File

@@ -1955,6 +1955,17 @@ 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);
}
}
void Explain_table_access::print_explain_json(Explain_query *query,
Json_writer *writer,
bool is_analyze)
@@ -2113,6 +2124,7 @@ void Explain_table_access::print_explain_json(Explain_query *query,
writer->add_member("r_other_time_ms").add_double(extra_time_tracker.get_time_ms());
}
trace_engine_stats(handler_for_stats, writer);
print_r_icp_filtered(handler_for_stats, tracker, writer);
}
/* `filtered` */