Well, if you can load the data in a distinct way in the script already there's no need for the count(distinct ). It does require a little bit of data model review to see if there's a viable way of replacing the count(distinct) functions from your front end.