Handle x=count(foo) better: there's no need to join to the lookup table to count distinct.