[Maria-developers] 97e932919bd: MDEV-22665: Print ranges in the optimizer trace created for non-indexed columns when optimizer_use_condition_selectivity >2
Hi Varun, Please find some minor comments below. Ok to push when addressed.
revision-id: 97e932919bd53b854e0cea0d0001d185d7e63cc0 (mariadb-10.4.11-199-g97e932919bd) parent(s): 0a5668f5128c731a346abf41afdc6fed33164ffc author: Varun Gupta committer: Varun Gupta timestamp: 2020-05-26 22:36:03 +0530 message:
MDEV-22665: Print ranges in the optimizer trace created for non-indexed columns when optimizer_use_condition_selectivity >2
Now the optimizer trace shows the ranges constructed while getting estimates from EITS
--- mysql-test/main/opt_trace.result | 94 ++++++++++++++++++++++++++++++ mysql-test/main/opt_trace.test | 18 ++++++ sql/field.cc | 40 +++++++++++++ sql/field.h | 1 + sql/opt_range.cc | 123 ++++++++++++++++++++++++++++----------- 5 files changed, 241 insertions(+), 35 deletions(-) ...
diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 66c870dd2ac..2cef483ef28 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc
@@ -15804,6 +15821,38 @@ void QUICK_GROUP_MIN_MAX_SELECT::dbug_dump(int indent, bool verbose)
#endif /* !DBUG_OFF */
+ +/* + @brief Print the comparison operator for the min range +*/ + +static void print_min_range_operator(String *out, const key_range key)
Do you really need to pass the whole struct key_range by value here? I think passing key.flag would be sufficient.
+{ + if (key.flag == HA_READ_AFTER_KEY) + out->append(STRING_WITH_LEN(" < ")); + else if (key.flag == HA_READ_KEY_EXACT || + key.flag == HA_READ_KEY_OR_NEXT) + out->append(STRING_WITH_LEN(" <= ")); + else + out->append(STRING_WITH_LEN(" ? ")); +} + + +/* + @brief Print the comparison operator for the max range +*/ + +static void print_max_range_operator(String *out, const key_range key) +{
Same as with print_min_range_operator: pass key.flag instead.
+ if (key.flag == HA_READ_BEFORE_KEY) + out->append(STRING_WITH_LEN(" < ")); + else if (key.flag == HA_READ_AFTER_KEY) + out->append(STRING_WITH_LEN(" <= ")); + else + out->append(STRING_WITH_LEN(" ? ")); +} + + static void print_range(String *out, const KEY_PART_INFO *key_part, KEY_MULTI_RANGE *range, uint n_key_parts)
BR Sergei -- Sergei Petrunia, Software Developer MariaDB Corporation | Skype: sergefp | Blog: http://s.petrunia.net/blog
participants (1)
-
Sergey Petrunia