I have a huge table, having a much smaller number (by orders of magnitude) of distinct values on some column x.
I need to do a query like SELECT D
When doing a SELECT DISTINCT on an indexed field, an index scan makes sense, as execution still has to scan each value in the index for the entire table (assuming no WHERE clause, as seems to be the case by your example).
Indexes usually have more of an impact on WHERE conditions, JOINS, and ORDER BY clauses.