gpt4 book ai didi

mysql - 为什么有索引的 MySQL 查询速度很慢?

转载 作者:行者123 更新时间:2023-11-30 23:46:23 24 4
gpt4 key购买 nike

以下查询大约需要 9 秒。这对我来说似乎很慢。知道为什么它这么慢吗?

mysql> explain SELECT ts, wert
-> FROM visu_werte_int v0_
-> WHERE v0_.wert_id = 163
-> AND v0_.ts <= '2016-01-25 23:00:00'
-> AND v0_.ts >= '2016-01-24 23:00:00';

Explain result

最佳答案

试试这个:

SELECT ts, wert 
FROM visu_werte_int v0_ WHERE v0_.wert_id = 163 AND v0_.ts BETWEEN '2016-01-223:00:00' AND '2016-01-25 23:00:00';

如果您遇到问题,请在您的 wert_id 列上创建索引,方法与此相同:

create index ix_visu_werte_int_search on visu_werte_int(wert_id,ts) using BTREE;

关于mysql - 为什么有索引的 MySQL 查询速度很慢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35010071/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com