[Commits] ee73b33: MDEV-8840: ANALYZE FORMAT=JSON produces wrong data with BKA

Varun varunraiko1803 at gmail.com
Sat Jun 17 15:05:41 EEST 2017


revision-id: ee73b331d97d33ae7aa1403a4ac7312f2d261754 (mariadb-10.1.20-323-gee73b33)
parent(s): 056bab0880544d91ea67d18fe8db65b4f6625482
author: Varun Gupta
committer: Varun Gupta
timestamp: 2017-06-17 17:34:07 +0530
message:

MDEV-8840: ANALYZE FORMAT=JSON produces wrong data with BKA

The issue was that r_loops, r_rows and r_filtered in ANALYZE FORMAT= JSON were not
calculated for the table on which we were performing the MRR scan in the BKA join
Fixed this by adding respective counter in the JOIN_CACHE_MRR::open and JOIN_CACHE::next

---
 mysql-test/r/explain_json.result | 6 +++---
 sql/sql_join_cache.cc            | 3 +++
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/mysql-test/r/explain_json.result b/mysql-test/r/explain_json.result
index 568373f..9046070 100644
--- a/mysql-test/r/explain_json.result
+++ b/mysql-test/r/explain_json.result
@@ -1524,12 +1524,12 @@ ANALYZE
         "key_length": "5",
         "used_key_parts": ["a"],
         "ref": ["test.t3.a"],
-        "r_loops": 0,
+        "r_loops": 1,
         "rows": 1,
-        "r_rows": null,
+        "r_rows": 11,
         "r_total_time_ms": "REPLACED",
         "filtered": 100,
-        "r_filtered": null,
+        "r_filtered": 90.909,
         "index_condition_bka": "((t4.b + 1) <= (t3.b + 1))"
       },
       "buffer_type": "flat",
diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc
index 1023aea..cf6362c 100644
--- a/sql/sql_join_cache.cc
+++ b/sql/sql_join_cache.cc
@@ -3877,6 +3877,7 @@ int JOIN_TAB_SCAN_MRR::open()
   /* Dynamic range access is never used with BKA */
   DBUG_ASSERT(join_tab->use_quick != 2);
 
+  join_tab->tracker->r_scans++;
   save_or_restore_used_tabs(join_tab, FALSE);
 
   init_mrr_buff();
@@ -3917,9 +3918,11 @@ int JOIN_TAB_SCAN_MRR::next()
   char **ptr= (char **) cache->get_curr_association_ptr();
 
   DBUG_ASSERT(sizeof(range_id_t) == sizeof(*ptr));
+  join_tab->tracker->r_rows++;
   int rc= join_tab->table->file->multi_range_read_next((range_id_t*)ptr) ? -1 : 0;
   if (!rc)
   {
+    join_tab->tracker->r_rows_after_where++;
     /*
       If a record in in an incremental cache contains no fields then the
       association for the last record in cache will be equal to cache->end_pos


More information about the commits mailing list