Updated all_tag_counts to use an additional select statement instead of a sub select which doesn't work well on large tables