diff options
| author | Sergei Petrunia <sergey@mariadb.com> | 2023-03-07 19:49:57 +0300 |
|---|---|---|
| committer | Sergei Petrunia <sergey@mariadb.com> | 2023-03-31 14:11:32 +0300 |
| commit | dc1d6213f9a5ad4a53d35a886f52adf4ee0a2b5c (patch) | |
| tree | a6a06b8d6a960ebf17ace01ffaf504c42b4335b5 /sql/sql_explain.cc | |
| parent | 169def14f64492466a305114b0ca13b2b5775164 (diff) | |
| download | mariadb-git-dc1d6213f9a5ad4a53d35a886f52adf4ee0a2b5c.tar.gz | |
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>
Diffstat (limited to 'sql/sql_explain.cc')
| -rw-r--r-- | sql/sql_explain.cc | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc index 480a1259ba8..caec818d130 100644 --- a/sql/sql_explain.cc +++ b/sql/sql_explain.cc @@ -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(); } } |
