gpt4 book ai didi

mysql - 优化 "COUNT(DISTINCT col) WHERE othercol = ?"速度

转载 作者:行者123 更新时间:2023-11-29 06:37:30 26 4
gpt4 key购买 nike

我有一个独特的计数,大约需要半分钟或更长时间才能得到结果。

select COUNT(DISTINCT ip) as unique_visits
from idevaff_iptracking
where acct_id = ? and stamp = ?

计算 IP 的更快方法是什么? ip 列上有索引,acct_id 上有 ip 列索引。

最佳答案

对于此查询:

select COUNT(DISTINCT ip) as unique_visits
from idevaff_iptracking
where acct_id = ? and stamp = ?

您想要在 idevaff_iptracking(acct_d, stamp, ip) 上建立索引。

关于mysql - 优化 "COUNT(DISTINCT col) WHERE othercol = ?"速度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53145942/

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