我有一个独特的计数,大约需要半分钟或更长时间才能得到结果。
select COUNT(DISTINCT ip) as unique_visits
from idevaff_iptracking
where acct_id = ? and stamp = ?
计算IP的更快方法是什么? ip列和带有ip列的acct_id上都有索引。
答案 0 :(得分:2)
对于此查询:
select COUNT(DISTINCT ip) as unique_visits
from idevaff_iptracking
where acct_id = ? and stamp = ?
您要在idevaff_iptracking(acct_d, stamp, ip)
上建立索引。