我有我要分析的这个 mysql 查询。它很慢,这里的访问者表大约有 50K 条目,这个查询永远不会返回。当我尝试解释语句时,我发现访问者表上没有使用索引,尽管索引可用。现在这是我需要帮助解决的大难题。任何提示表示赞赏。
询问:
select distinct
visitor0_.ID as ID130_,
case when visitor0_1_.id is not null then 1 when
visitor0_.ID is not null then 0
end as clazz_
from Visitor visitor0_
left outer join Operator visitor0_1_ on visitor0_.ID=visitor0_1_.id
where (visitor0_.ID not in
(select operator1_.id
from Operator operator1_
inner join Visitor operator1_1_ on operator1_.id=operator1_1_.ID))
and (exists
(select visitorpro2_.ID
from VisitorProfileField visitorpro2_, ProfileField profilefie3_
where visitorpro2_.profileFieldID=profilefie3_.ID
and visitorpro2_.visitorID=visitor0_.ID
and profilefie3_.name='subscription86'
and visitorpro2_.numberVal=1
and visitorpro2_.stringVal='Manual'))
解释输出屏幕截图: http: //grab.by/grabs/9c3a629a25fc4e9ec0fa54355d4a092c.png