Re: Select count(*) on a 2B Rows Tables Takes ~20 Hours

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Fd Habash <fmhabash(at)gmail(dot)com>
Cc: "pgsql-performance(at)lists(dot)postgresql(dot)org" <pgsql-performance(at)lists(dot)postgresql(dot)org>
Subject: Re: Select count(*) on a 2B Rows Tables Takes ~20 Hours
Date: 2018-09-13 18:05:32
Message-ID: 20180913180532.GD11702@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Thu, Sep 13, 2018 at 01:33:54PM -0400, Fd Habash wrote:
> Is this ET expected? If not, what could be slowing it down? I’m currently running explain analyze and I’ll share the final output when done.

explain(analyze,BUFFERS) is what's probably interesting

You're getting an index-only-scan, but maybe still making many accesses to the
heap (table) for pages which aren't all-visible. You can maybe improve by
vacuuming (perhaps by daily cronjob or by ALTER TABLE SET autovacuum threshold
or scale factor).

--
Justin Pryzby
System Administrator
Telsasoft
+1-952-707-8581

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2018-09-13 18:12:02 Re: Select count(*) on a 2B Rows Tables Takes ~20 Hours
Previous Message Fd Habash 2018-09-13 17:33:54 Select count(*) on a 2B Rows Tables Takes ~20 Hours