perf(messages): Using a single query to fetch metastrings when counting ...

...unread messages.

Fixes #6640.