Home  >  Q&A  >  body text

mysql - UNION ALL 的效率很差么?

有3个结构类似的表(内容类型不一样),我想用 UNION ALL 做一个 TIMELINE(时间倒序排列),请问这个函数效率是否很差(以前用过一次,确实不理想,可能当时没有很好的利用索引)

大家讲道理大家讲道理2743 days ago714

reply all(1)I'll reply

  • 迷茫

    迷茫2017-04-17 14:25:33

    UNION ALL itself is not bad. What UNION ALL has to do is very simple, which is to merge multiple result sets, without involving operations or the like.

    According to your needs, you need to sort by time after UNION ALL. . . Indeed, the index is no longer valid at this time.
    If the amount of data is large, it should be very slow.

    So, you should think about how much data this TIMELINE needs to display.

    reply
    0
  • Cancelreply