Speed up group purging by using joined query.