Improve efficiency of Group.get_unique_tags query