A method to avoid OOM when count(distinct) by providing ExternalSet