Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gK5Ku-00053V-SN for pgsql-general@arkaria.postgresql.org; Tue, 06 Nov 2018 17:40:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gK5Kt-0001Ep-5S for pgsql-general@arkaria.postgresql.org; Tue, 06 Nov 2018 17:40:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gK5Ks-0001EP-SW for pgsql-general@lists.postgresql.org; Tue, 06 Nov 2018 17:40:18 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gK5Kq-0004NX-7c for pgsql-general@lists.postgresql.org; Tue, 06 Nov 2018 17:40:18 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id wA6HeBAZ026568; Tue, 6 Nov 2018 12:40:11 -0500 From: Tom Lane To: Ravi Krishna cc: pgsql-general@lists.postgresql.org Subject: Re: why select count(*) consumes wal logs In-reply-to: <653931906.1147337.1541523848244@mail.yahoo.com> References: <653931906.1147337.1541523848244.ref@mail.yahoo.com> <653931906.1147337.1541523848244@mail.yahoo.com> Comments: In-reply-to Ravi Krishna message dated "Tue, 06 Nov 2018 17:04:08 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <26566.1541526011.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 06 Nov 2018 12:40:11 -0500 Message-ID: <26567.1541526011@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Ravi Krishna 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 ac= tivity. > 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 no= thing. 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