J'explique une requête dans mysql5.7.16, je ne peux pas comprendre ce que signifie "Sélectionner des tables optimisées" dans le plan. Je cherche depuis longtemps sur google, mais pas d'utilisation. qui peut me donner des idées? merci!que signifie «Sélectionner des tables optimisées» dans le plan d'exécution mysql5.7?
le scénario est ci-dessous:
([email protected])[(none)]>desc select count(F02) from S65.T6507;
+----+-------------+-------+------------+------+---------------+------+---------+------+------+----------+------------------------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+-------+------------+------+---------------+------+---------+------+------+----------+------------------------------+
| 1 | SIMPLE | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | Select tables optimized away |
+----+-------------+-------+------------+------+---------------+------+---------+------+------+----------+------------------------------+
1 row in set, 1 warning (0.00 sec)
([email protected])[(none)]>show index from S65.T6507;
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| T6507 | 0 | PRIMARY | 1 | F01 | A | 18364472 | NULL | NULL | | BTREE | | |
| T6507 | 1 | F03 | 1 | F03 | A | 69338 | NULL | NULL | | BTREE | | |
| T6507 | 1 | F02 | 1 | F02 | A | 18364472 | NULL | NULL | | BTREE | | |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
3 rows in set (0.00 sec)
([email protected])[(none)]>show create table S65.T6507 \G
*************************** 1. row ***************************
Table: T6507
Create Table: CREATE TABLE `T6507` (
`F01` int(10) unsigned NOT NULL COMMENT 'xxx',
`F02` int(10) unsigned NOT NULL COMMENT 'xxx',
`F03` int(10) unsigned NOT NULL COMMENT 'xxx',
`F04` decimal(20,2) unsigned NOT NULL COMMENT '..',
`F05` decimal(20,2) unsigned NOT NULL COMMENT '..',
`F06` decimal(20,2) unsigned NOT NULL COMMENT '..',
`F07` int(10) unsigned DEFAULT NULL COMMENT '.',
`F08` int(10) unsigned DEFAULT NULL COMMENT '..',
PRIMARY KEY (`F01`),
KEY `F03` (`F03`) USING BTREE,
KEY `F02` (`F02`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='xxx'
1 row in set (0.00 sec)
myql version:
mysql Ver 14.14 Distrib 5.7.16, for linux-glibc2.5 (x86_64) using EditLine wrapper
Server version: 5.7.16-enterprise-commercial-advanced-log MySQL Enterprise Server - Advanced Edition (Commercial)
voulez-vous dire que la requête utilisant l'index pour numériser? cette table a trois index: F02, F03 et PRIMARY, comment puis-je savoir lequel est utilisé? – elison
Le seul qui compte est l'index sur 'F02', puisque vous écrivez' COUNT (F02) '. – Barmar