gpt4 book ai didi

Mysql 分组查询需要 30 多秒才能执行

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

我正在尝试执行以下查询

select COUNT(*) from tbl_impressions group by spackage 

一开始执行它大约需要 40 秒,但几次后相同的查询会在 2 秒内执行。

有谁知道原因吗?

PS:所有表都已经编入索引。

提前致谢。

最佳答案

发生这种情况的原因如下:

The query cache stores the text of a SELECT statement together with the corresponding result that was sent to the client. If an identical statement is received later, the server retrieves the results from the query cache rather than parsing and executing the statement again. The query cache is shared among sessions, so a result set generated by one client can be sent in response to the same query issued by another client.

更多文档请看这里http://dev.mysql.com/doc/refman/5.1/en/query-cache.html

关于Mysql 分组查询需要 30 多秒才能执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21675246/

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