MySQL索引差异

MySQL索引差异,mysql,sql,indexing,explain,Mysql,Sql,Indexing,Explain,我有一个查询,它在mysql服务器的两个不同实例中具有不同的性能,这两个实例的表和索引显然是相同的。以下是查询: select t.id, t.artist, t.title, count(*) from `raw_detection` r, tracks t where t.id = r.`track_id` and r.duplicated = false and (t.title = '' or t.title is null or t.artist = '' or t.artist is

我有一个查询,它在mysql服务器的两个不同实例中具有不同的性能,这两个实例的表和索引显然是相同的。以下是查询:

select t.id, t.artist, t.title, count(*) from `raw_detection` r, tracks t where t.id = r.`track_id`
and r.duplicated = false
and (t.title = '' or t.title is null or t.artist = '' or t.artist is null)
group by 1,2,3
order by count(*) desc;
当我对此查询进行解释时,fast服务器会响应:

id  s_type  table   type  possible_keys    key  key_len ref rows Extra   
1   SIMPLE  t   index_merge PRIMARY,index_tracks_on_title,index_tracks_on_artist    index_tracks_on_title,index_tracks_on_artist    602,602 NULL    11812   Using sort_union(index_tracks_on_title,index_tracks_on_artist); Using where; Using temporary; Using filesort
1   SIMPLE  r   ref index_raw_detection_on_duplicated_and_created_at,index_raw_detection_on_track_id    index_raw_detection_on_track_id 4   playax.t.id 84  Using where
而慢速服务器则不同:

id  s_type  table   type  possible_keys    key  key_len ref rows Extra   
1   SIMPLE  t   ALL PRIMARY,index_tracks_on_title,index_tracks_on_artist    NULL    NULL    NULL    177313  Using where; Using temporary; Using filesort
1   SIMPLE  r   ref index_raw_detection_on_duplicated_and_created_at,index_raw_detection_on_track_id    index_raw_detection_on_track_id 4   playax.t.id 20  Using where

为什么会发生这种情况?

这不应该是t.title=或t.title为null或t.artist=或t.artist为null吗?谢谢@JoachimIsaksson-我解决了这个问题尝试更新两个表上的统计信息并重新运行查询。可用资源用于确定mysql使用哪个查询计划,以便确定您的服务器是否有不同的硬件或负载,这些硬件或负载可能是mysql的一部分