mirror of
https://github.com/MariaDB/server.git
synced 2025-08-05 13:16:09 +03:00
MDEV-30806: ANALYZE FORMAT=JSON: better support for BNL and BNL-H joins
In block-nl-join, add: - r_loops - this shows how many incoming record combinations this query plan node had. - r_effective_rows - this shows the average number of matching rows that this table had for each incoming record combination. This is comparable with r_rows in non-blocked access methods. For BNL-joins, it is always equal to $.table.r_rows * $.table.r_filtered For BNL-H joins the value cannot be computed from other values Reviewed by: Monty <monty@mariadb.org>
This commit is contained in:
@@ -1891,12 +1891,29 @@ void Explain_table_access::print_explain_json(Explain_query *query,
|
||||
|
||||
if (is_analyze)
|
||||
{
|
||||
//writer->add_member("r_loops").add_ll(jbuf_tracker.get_loops());
|
||||
writer->add_member("r_loops").add_ll(jbuf_loops_tracker.get_loops());
|
||||
|
||||
writer->add_member("r_filtered");
|
||||
if (jbuf_tracker.has_scans())
|
||||
writer->add_double(jbuf_tracker.get_filtered_after_where()*100.0);
|
||||
else
|
||||
writer->add_null();
|
||||
/*
|
||||
effective_rows is average number of matches we got for an incoming
|
||||
row. The row is stored in the join buffer and then is read
|
||||
from there, possibly multiple times. We can't count this number
|
||||
directly. Infer it as:
|
||||
total_number_of_row_combinations_considered / r_loops.
|
||||
*/
|
||||
writer->add_member("r_effective_rows");
|
||||
if (jbuf_loops_tracker.has_scans())
|
||||
{
|
||||
double loops= (double)jbuf_loops_tracker.get_loops();
|
||||
double row_combinations= (double)jbuf_tracker.r_rows;
|
||||
writer->add_double(row_combinations / loops);
|
||||
}
|
||||
else
|
||||
writer->add_null();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user