相关疑难解决方法(0)

SELECT语句不使用possible_keys

我有一个遗留系统的表,没有主键.它记录了工厂发布材料的交易数据.

为简单起见,我们可以说每行包含job_number,part_number,quantity&date_issued.

我在日期发布列中添加了一个索引.当我运行EXPLAIN SELECT*FROM issued_pa​​rts WHERE date_issued>'20100101'时,它显示如下:

+----+-------------+----------------+------+-------------------+------+---------+------+---------+-------------+
| id | select_type | table          | type | possible_keys     | key  | key_len | ref  | rows    | Extra       |
+----+-------------+----------------+------+-------------------+------+---------+------+---------+-------------+
|  1 | SIMPLE      | issued_parts   | ALL  | date_issued_alloc | NULL | NULL    | NULL | 9724620 | Using where |
+----+-------------+----------------+------+-------------------+------+---------+------+---------+-------------+

所以它看到了关键,但它不使用它?有人可以解释原因吗?

mysql indexing select explain

10
推荐指数
1
解决办法
5982
查看次数

MYSQL未使用可能的密钥

我有一个名为“ element”的主表:

CREATE TABLE `element` (
  `elements_id` int(11) NOT NULL AUTO_INCREMENT,
  `elements_code` varchar(32) DEFAULT NULL,
  `elements_name` varchar(128) DEFAULT NULL,
  `elements_description` text,
  `elements_image` varchar(64) DEFAULT NULL,
  `attribute_category_id` int(11) DEFAULT '0',
  `attribute_material_id` int(11) DEFAULT '0',
  `attribute_color_id` int(11) DEFAULT '0',
  `attribute_shape_id` int(11) DEFAULT '0',
  `attribute_surface_id` int(11) DEFAULT '0',
  `attribute_size_id` int(11) DEFAULT '0',
  `attribute_holesize_id` int(11) DEFAULT '0',
  `attribute_cut_id` int(11) DEFAULT '0',
  `attribute_height_id` int(11) NOT NULL DEFAULT '0',
  `attribute_width_id` int(11) NOT NULL DEFAULT '0',
  `attribute_thickness_id` int(11) NOT NULL DEFAULT '0',
  `attribute_clasp_id` int(11) NOT NULL DEFAULT …
Run Code Online (Sandbox Code Playgroud)

php mysql

5
推荐指数
1
解决办法
744
查看次数

标签 统计

mysql ×2

explain ×1

indexing ×1

php ×1

select ×1