distinct and count must run in server memory, commented out for now