Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hdkLW-00065i-Rc for pgsql-admin@arkaria.postgresql.org; Wed, 19 Jun 2019 23:50:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hdkLT-0004Bm-Nk for pgsql-admin@arkaria.postgresql.org; Wed, 19 Jun 2019 23:50:27 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hdkLT-000452-4M for pgsql-admin@lists.postgresql.org; Wed, 19 Jun 2019 23:50:27 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hdkLP-0002Mr-Eg for pgsql-admin@postgresql.org; Wed, 19 Jun 2019 23:50:25 +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 x5JNoMLj031038; Wed, 19 Jun 2019 19:50:22 -0400 From: Tom Lane To: "S. Bob" cc: pgsql-admin Subject: Re: Vacuum not cleaning up rows. In-reply-to: <15eddc60-6441-e55e-f742-bd7ea37f1873@quadratum-braccas.com> References: <15eddc60-6441-e55e-f742-bd7ea37f1873@quadratum-braccas.com> Comments: In-reply-to "S. Bob" message dated "Wed, 19 Jun 2019 17:39:53 -0600" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <31036.1560988222.1@sss.pgh.pa.us> Date: Wed, 19 Jun 2019 19:50:22 -0400 Message-ID: <31037.1560988222@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk "S. Bob" writes: > we have a table that consistently has 2x the number of dead rows than > live rows. > I've done some digging and it looks like somehow the application is > holding shared locks that force vacuum to not cleanup rows. This is not a locking issue; if it were, vacuum would be unable to scan the table at all. What it is is a snapshot issue: that is, some transaction has a snapshot that's old enough to allow it to see those dead rows if it were to look. So vacuum can't remove the rows for fear of causing transactional consistency failures. What you want to do is look into pg_stat_activity for transactions with very old start times, and then cancel them or otherwise force them to terminate. Also, if there are no obvious candidates there, you might be having a problem with prepared transactions --- look into pg_prepared_xacts to see if there are any old ones of those. regards, tom lane