我有一个选择来获取警报。
select 'comments' prefix, c.foto, c.data as data, c.user, concat(k.user, ' comments your post') as logs from comentarios c
inner join posts p on c.foto = p.id
inner join cadastro k on c.user = k.id
where p.user = 1 and p.user <> c.user and c.delete = 0
union all
select 'like' prefix, l.post, l.data as data, l.user, concat(k.user, ' liked your post') as logs from likes l
inner join posts p on l.post = p.id
inner join cadastro k on l.user = k.id
where p.user = 1 and l.user <> p.user
order by data desc
limit 5
问题是如果我以这种方式运行选择,则需要2.4871秒。
如果我删除了select 'like'...
= 0.0024,但如果我将此选择分开,则只有0.010而没有数据描述的顺序。
任何想法为什么?我不知道问题是工会还是订单...... 它们都被很好地编入索引。