MySQL为什么将限制从20增加到21将执行时间从1,4s减少到0,0067s

时间:2018-07-04 13:30:36

标签: mysql

我有一个包含23万行的表格
查询1个持续时间1,389秒

SELECT sql_no_cache `model_regulation_sections`.* 
FROM `model_regulation_sections` 
WHERE `model_regulation_sections`.`regulation_id` = 254 
ORDER BY `model_regulation_sections`.`lft` ASC 
LIMIT 20

说明
select_type =简单
表格= model_regulation_sections
partitions = null`
类型=索引
可能的键= document_id
键= lft
key_len = 4
ref = null
行= 2229
已过滤= 0.90
额外=使用where

查询2持续时间0,0067

SELECT sql_no_cache `model_regulation_sections`.* 
FROM `model_regulation_sections` 
WHERE `model_regulation_sections`.`regulation_id` = 254 
ORDER BY `model_regulation_sections`.`lft` ASC 
LIMIT 21

说明
select_type =简单
表格= model_regulation_sections
partitions = null`
类型= ref
可能的键= document_id
键= lft
key_len = 4
ref = const
行= 2251
已过滤= 100
Extra ='使用索引条件;使用filesort'

MySQL为什么将限制从20增加到21将执行时间从1,4s减少到0,0067s?

为什么2个小时前查询1的执行时间为13.5秒? 我没有更改配置。

0 个答案:

没有答案
相关问题