| Bug #83062 | it's no longer possible to determine used key parts by looking at key_length | ||
|---|---|---|---|
| Submitted: | 20 Sep 2016 13:18 | Modified: | 21 Sep 2016 8:13 |
| Reporter: | Kenny Gryp | Email Updates: | |
| Status: | Verified | Impact on me: | |
| Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
| Version: | 5.6.32, 5.7.14, 5.6.33, 5.7.15 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | explain, MySQL, Optimizer | ||
[20 Sep 2016 13:18]
Kenny Gryp
[20 Sep 2016 18:35]
Kenny Gryp
Same in MySQL 5.7.14:
db1-T9 mysql> set optimizer_switch='index_condition_pushdown=off';
Query OK, 0 rows affected (0.00 sec)
db1-T9 mysql> explain format=json select * from title where production_year between 1990 and 2000 and title like 'B%'\G
*************************** 1. row ***************************
EXPLAIN: {
"query_block": {
"select_id": 1,
"cost_info": {
"query_cost": "180648.61"
},
"table": {
"table_name": "title",
"access_type": "range",
"possible_keys": [
"idx_title_production_year"
],
"key": "idx_title_production_year",
"used_key_parts": [
"title"
],
"key_length": "67",
"rows_examined_per_scan": 129034,
"rows_produced_per_join": 14335,
"filtered": "11.11",
"cost_info": {
"read_cost": "177781.47",
"eval_cost": "2867.14",
"prefix_cost": "180648.61",
"data_read_per_join": "3M"
},
"used_columns": [
"id",
"title",
"imdb_index",
"kind_id",
"production_year",
"imdb_id",
"phonetic_code",
"episode_of_id",
"season_nr",
"episode_nr",
"series_years",
"title_crc32"
],
"attached_condition": "((`imdb`.`title`.`production_year` between 1990 and 2000) and (`imdb`.`title`.`title` like 'B%'))"
}
}
}
1 row in set, 1 warning (0.00 sec)
[21 Sep 2016 8:13]
MySQL Verification Team
Hello Kenny, Thank you for the report and test case. Observed this with 5.6.33 build. Thanks, Umesh
[21 Sep 2016 8:17]
MySQL Verification Team
-- 5.7.15
[umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-advanced-5.7.15: bin/mysql -uroot -S /tmp/mysql_ushastry.sock imdb
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.15-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> set optimizer_switch='index_condition_pushdown=off';
Query OK, 0 rows affected (0.00 sec)
mysql> explain format=json select * from title where production_year between 1990 and 2000 and title like 'B%'\G
*************************** 1. row ***************************
EXPLAIN: {
"query_block": {
"select_id": 1,
"cost_info": {
"query_cost": "174231.01"
},
"table": {
"table_name": "title",
"access_type": "range",
"possible_keys": [
"idx_title_production_year"
],
"key": "idx_title_production_year",
"used_key_parts": [
"title"
],
"key_length": "67",
"rows_examined_per_scan": 124450,
"rows_produced_per_join": 13826,
"filtered": "11.11",
"cost_info": {
"read_cost": "171465.73",
"eval_cost": "2765.28",
"prefix_cost": "174231.01",
"data_read_per_join": "3M"
},
"used_columns": [
"id",
"title",
"imdb_index",
"kind_id",
"production_year",
"imdb_id",
"phonetic_code",
"episode_of_id",
"season_nr",
"episode_nr",
"series_years",
"title_crc32"
],
"attached_condition": "((`imdb`.`title`.`production_year` between 1990 and 2000) and (`imdb`.`title`.`title` like 'B%'))"
}
}
}
1 row in set, 1 warning (0.00 sec)
[24 Apr 2018 20:15]
Matthew Boehm
Any updates on this? I just love telling people that EXPLAIN isn't accurate (/sarcasm).
