Hacker News new | ask | show | jobs
by takeda 3697 days ago
Try:

    SELECT COUNT(*) FROM (SELECT DISTINCT x FROM table) AS temp;

The

    SELECT COUNT(DISTINCT x))
Is slow because it performs sort.