SELECT ID,uye,kazanilacakmiktar FROM kupon WHERE durum=0 AND ID IN (
select c.kupon
from kuponbahis c join
bahis b
on ((b.sonuc = c.secim) OR (b.sonuc=5)) and b.ID = c.bahis
group by c.kupon
having sum(c.bahis = '999') > 0 and
count(*) = (SELECT COUNT(*) FROM kuponbahis WHERE kupon = c.kupon));
我有这样的查询。我在
kupon.ID, kupon.uye, kupon.kazanilacakmiktar, kuponbahis.bahis, kuponbahis.secim
处有索引,但它仍具有重要的运行时。我想念的是什么,我做错了什么?
最佳答案
该查询的明显索引为:kupon(durum, id)
kuponbahis(kupon)
bahis(id, sonuc)
但是,我不相信这些索引将对他的查询有很大帮助。查询相当复杂,并且可能存在其他表达逻辑的方式。
关于php - 在MySQL中要索引哪些列?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37535042/