Don't retrieve all offline messages only to count them.
Description
The implementation in Openfire of XEP-0013 retrieves all messages from the database, only to return a count of unread messages. That is not very effective. Instead, use a database query that sums rows (which is already available).