From: Tomas Vondra <tomas.vondra@enterprisedb.com>
To: basti <mailinglist@unix-solution.de>
To: pgsql-general@lists.postgresql.org
Subject: Re: Query take a long time and use no index
Date: Mon, 17 Jul 2023 13:21:36 +0200
Message-ID: <7599651d-7269-ec5b-b968-46795a76c375@enterprisedb.com> (raw)
In-Reply-To: <d9708792-19fc-2dc7-4ecf-f93b69a4c2b0@enterprisedb.com>
References: <5f826baf-e345-48a8-5672-db07add3e6b2@unix-solution.de>
<d9708792-19fc-2dc7-4ecf-f93b69a4c2b0@enterprisedb.com>
On 7/17/23 13:20, Tomas Vondra wrote:
> ...
>
> It's always going to be slow with the COUNT(DISTINCT), I'm afraid.
>
> Not sure how much you can modify the query / database, and how accurate
> results you need. If you're OK with estimates, you can try postgres-hll
> extension [2] which estimates count(distinct). For exact reaults, I
> wrote count_distinct extension [2] that uses hashtable. Might be worth a
> try, I guess.
>
Damn, I forgot to add the links:
[1] https://github.com/citusdata/postgresql-hll
[2] https://github.com/tvondra/count_distinct
regards
--
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tomas.vondra@enterprisedb.com, mailinglist@unix-solution.de
Subject: Re: Query take a long time and use no index
In-Reply-To: <7599651d-7269-ec5b-b968-46795a76c375@enterprisedb.com>
References: <5f826baf-e345-48a8-5672-db07add3e6b2@unix-solution.de> <d9708792-19fc-2dc7-4ecf-f93b69a4c2b0@enterprisedb.com> <7599651d-7269-ec5b-b968-46795a76c375@enterprisedb.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox