Here's the table in Postgresql:
name, ts, value
A, 2017-05-28, 1
A, 2017-05-27, 5
A, 2017-05-26, 2
...
B, 2017-05-28, 9
B, 2017-05-28, 12
...
The size of the table will be over 10 million. I'm trying to execute select count(distinct(name)) from "table"; and it takes me over 240s without ending. Could anyone give some suggestions regarding the way to optimise this scenario, like adding partition like Hive or adding index (which needs to be unique, but the name is duplicate across multiple records). Thanks!