开发者生态
morning
BETWEEN和>=and<=的查询时间为什么会差出1秒多?
摘要
select count(*) total,enroll_id from nw_enroll_votes where created_at>='2026-07-25 00:00:00' and created_at<='2026-08-02 23:59:59' and state=1 and type=1 GROUP BY enroll_id ORDER BY total DESC limit 1...
and
total
enroll_id
2026
created_at
select
count
from
nw_enroll_votes
where
2026-08-01
1 阅读
约1分钟阅读
勇敢的心
字号:
select count(*) Total,enroll_id from nw_enroll_votes 其中created_at>='2026-07-25 00:00:00'且created_at<='2026-08-02 23:59:59'且state=1且type=1 GROUP BY enroll_id ORDER BY总DESC限制10; 这条SQL的运行时间是1.9秒左右 select count(*) Total,enroll_id from nw_enroll_votes where state=1 and type=1 andcreated_at BETWEEN '2026-07-25 00:00:00' and '2026-08-02 23:59:59' GROUP BY enroll_id ORDER BY Total DESC limit 10; 这条SQL的运行时间是3.4秒左右,这占用sql的执行计划也是一模一样的,为什么会有这么大的时间查询呢?
这篇文章对您有帮助吗?
订阅66必读
每日精选科技资讯,直达你的邮箱