@KevinSaquing, Yes you are doing a nice way to get all messages from community by using count query first. Are you going to show this somewhere in your community? If YES, then you will mess-up with performance issue on community for this page. If you are doing this for export messages, try to make it using limit the query and add page_size for next numbers of results in the your query.
... View more