From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ravi Krishna <srkrishna1@aol.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: why select count(*) consumes wal logs
Date: Tue, 06 Nov 2018 12:40:11 -0500
Message-ID: <26567.1541526011@sss.pgh.pa.us> (raw)
In-Reply-To: <653931906.1147337.1541523848244@mail.yahoo.com>
References: <653931906.1147337.1541523848244.ref@mail.yahoo.com>
<653931906.1147337.1541523848244@mail.yahoo.com>
Ravi Krishna <srkrishna1@aol.com> writes:
> I loaded 133 million rows to a wide table (more than 100 cols) via COPY. The table has
> no index at this time. Since I am the only user I don't see any other activity.
> Now when I run select count(*) on the table where I just loaded data, it runs for ever,
> more than 10min and still running. Intrigued, I checked locks and saw nothing. Then I noticed something
> strange. When select count(*) runs, PG is writing to wal_logs, and that too a large amount. Why?
That represents setting the yes-this-row-is-committed hint bits on the
newly loaded rows. The first access to any such row will set that bit,
whether it's a select or a VACUUM or whatever.
regards, tom lane
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: tgl@sss.pgh.pa.us, srkrishna1@aol.com
Subject: Re: why select count(*) consumes wal logs
In-Reply-To: <26567.1541526011@sss.pgh.pa.us>
References: <653931906.1147337.1541523848244.ref@mail.yahoo.com> <653931906.1147337.1541523848244@mail.yahoo.com> <26567.1541526011@sss.pgh.pa.us>
* 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