It would be nice to implement a time based pagination cursor instead of the current limit ofset strategy for outgoing messages. As the number of outgoing messages increases the query gets slower and slower.
I don't know Rails enough to implement the functionality, I would appreciate if you guide somehow on the implementation or consider the problem.