&gt; There&#x27;s no reason for SELECT COUNT(DISTINCT x)) to perform badly in Postgres, as long as you have an appropriate table design and indexes.<p>Meh. Postgres&#x27; planner doesn&#x27;t know how to generate a skip-scan&#x2F;loose index scan for DISTINCT. You can write it yourself, but it&#x27;s a bit painful:
<a href="https:&#x2F;&#x2F;wiki.postgresql.org&#x2F;wiki&#x2F;Loose_indexscan" rel="nofollow">https:&#x2F;&#x2F;wiki.postgresql.org&#x2F;wiki&#x2F;Loose_indexscan</a><p>If you have a low cardinality that can be a <i>huge</i> efficiency difference.