Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lhZMF-0005qY-Uq for pgsql-performance@arkaria.postgresql.org; Fri, 14 May 2021 15:04:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lhZME-0000Sh-NR for pgsql-performance@arkaria.postgresql.org; Fri, 14 May 2021 15:04:06 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lhZME-0000SZ-FC for pgsql-performance@lists.postgresql.org; Fri, 14 May 2021 15:04:06 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lhZMC-0004G7-GO for pgsql-performance@postgresql.org; Fri, 14 May 2021 15:04:05 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 14EF42T81884332; Fri, 14 May 2021 11:04:02 -0400 From: Tom Lane To: Marcin Gozdalik cc: pgsql-performance@postgresql.org Subject: Re: Very slow "bloat query" In-reply-to: References: Comments: In-reply-to Marcin Gozdalik message dated "Fri, 14 May 2021 11:06:33 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1884330.1621004642.1@sss.pgh.pa.us> Date: Fri, 14 May 2021 11:04:02 -0400 Message-ID: <1884331.1621004642@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Marcin Gozdalik writes: > I have traced the problem to the bloated `pg_class` (the irony: `pgmetrics` > does not collect bloat on `pg_catalog`): > `vacuum (full, analyze, verbose) pg_class;` > ``` > INFO: vacuuming "pg_catalog.pg_class" > INFO: "pg_class": found 1 removable, 7430805 nonremovable row versions in > 158870 pages > DETAIL: 7429943 dead row versions cannot be removed yet. Ugh. It's understandable that having a lot of temp-table traffic would result in the creation of lots of dead rows in pg_class. The question to be asking is why aren't they vacuumable? You must have a longstanding open transaction somewhere (perhaps a forgotten prepared transaction?) that is holding back the global xmin horizon. Closing that out and then doing another manual VACUUM FULL should help. regards, tom lane