https://github.com/tvondra/count_distinct/
count_distinct provides an alternative to COUNT(DISTINCT ...) which for large amounts of data often ends in sorting and poor performance.
The PostgreSQL RPM repository uses PostgreSQL version numbers in the RPM packages. For example count_distinct for PostgreSQL 17 is named as count_distinct_17. Similarly count_distinct for PostgreSQL 15 is named as count_distinct_15.
count_distinct provides the following subpackages:
Install PGDG repository from: https://yum.postgresql.org/repopackages/
OS | Command |
---|---|
RHEL / Rocky Linux / AlmaLinux / Fedora | dnf install count_distinct_17 (or change the version as described above) |
Connect to the database that you want to create the extension as superuser and run:
CREATE EXTENSION count_distinct;
PostgreSQL version(s) | OS version | Arch | Status |
---|---|---|---|
17,16,15,14,13 | RHEL / Rocky Linux / AlmaLinux 9 | x86_64, aarch64 | Available |
17,16,15,14,13 | RHEL / Rocky Linux / AlmaLinux 8 | x86_64, aarch64 | Available |
17,16,15,14,13 | Fedora Linux | x86_64 | Available |