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.
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.