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 1lmJ0E-0003rK-3x for pgsql-admin@arkaria.postgresql.org; Thu, 27 May 2021 16:36:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lmJ0C-00075G-6O for pgsql-admin@arkaria.postgresql.org; Thu, 27 May 2021 16:36:56 +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 1lmJ0B-000758-BD for pgsql-admin@lists.postgresql.org; Thu, 27 May 2021 16:36:55 +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 1lmJ09-0003pl-65 for pgsql-admin@postgresql.org; Thu, 27 May 2021 16:36:54 +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 14RGap0g1785392; Thu, 27 May 2021 12:36:51 -0400 From: Tom Lane To: Wells Oliver cc: pgsql-admin Subject: Re: Mat view sometimes taking 10x the time to refresh concurrently In-reply-to: References: Comments: In-reply-to Wells Oliver message dated "Thu, 27 May 2021 09:15:12 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1785390.1622133411.1@sss.pgh.pa.us> Date: Thu, 27 May 2021 12:36:51 -0400 Message-ID: <1785391.1622133411@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Wells Oliver writes: > Hey, we have a mat view that normally takes ~18m to re-materialize > concurrently, which we do daily. Maybe once a week, it takes ~180m to > refresh, and we're at a loss as to why. > We are running backs during the same general time window, where we do > backup the schema where this mat view is located, could this be an issue? > We have not noticed any lock errors in the backup or log, though. > Any tips on tracing this down would be appreciated. My own mindset would be to wonder if a different/worse plan is being chosen. You could investigate that perhaps by running an EXPLAIN on the matview's query just before each refresh, to see if it changes. Checking pg_locks for ungranted locks while the REFRESH is running would be good to do too, although I'd think that a backup vs. a concurrent refresh shouldn't have that sort of problem. It seems possible also that you're just maxing out the machine's I/O capacity between these two tasks. regards, tom lane