Improve SQL request in get_threads_of in Message model to reduce SELECT calls