Re: [RFC] speed up count(*)

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Joe Conway <mail(at)joeconway(dot)com>
Cc: John Naylor <john(dot)naylor(at)enterprisedb(dot)com>, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [RFC] speed up count(*)
Date: 2021-10-21 20:06:29
Message-ID: CA+TgmoYrwq7uTufUMhFC6+f9hwUaSvxQ1gTa=NAxpAcoah7_Kw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Oct 21, 2021 at 9:09 AM Joe Conway <mail(at)joeconway(dot)com> wrote:
> I think you are exactly correct. People seem to understand that with a
> predicate it is harder, but they expect
>
> select count(*) from foo;
>
> to be nearly instantaneous, and they don't really need it to be exact.
> The stock answer for that has been to do
>
> select reltuples from pg_class
> where relname = 'foo';
>
> But that is unsatisfying because the problem is often with some
> benchmark or another that cannot be changed.

I would also expect it to almost always give the wrong answer.

--
Robert Haas
EDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Christensen 2021-10-21 20:07:17 Re: CREATE ROLE IF NOT EXISTS
Previous Message Bossart, Nathan 2021-10-21 19:51:47 Re: parallelizing the archiver