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 1hAzuF-0005Bu-Ji for pgsql-general@arkaria.postgresql.org; Mon, 01 Apr 2019 16:35:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hAzuC-0004VJ-Uu for pgsql-general@arkaria.postgresql.org; Mon, 01 Apr 2019 16:35:28 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1hAzuC-0004Tf-Em for pgsql-general@lists.postgresql.org; Mon, 01 Apr 2019 16:35:28 +0000 Received: from smtp40.i.mail.ru ([94.100.177.100]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hAzu9-0001Bk-1w for pgsql-general@postgresql.org; Mon, 01 Apr 2019 16:35:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail2; h=Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject; bh=H7dOxYNDqn7/uuyVky4jm+TPGSXlS+5wiLHt0HG1ChA=; b=qWS4r5vr+MxNmfOGD/FAcpxqovL/wfq318LbDuVv16CE3vHU6VR2SIlISqwg2dGVVcfa+4mJVxytsPnVt/HYNyNYDcc9BaVeZZHRu0+UwYuz+mRytSm+58ihnwZ/0of6/FyBmZQUU/Xc/+Wv7KRFIJ+RHMSQhWhNxxSjWZOz3QI=; Received: by smtp40.i.mail.ru with esmtpa (envelope-from ) id 1hAzu6-0004G2-DZ; Mon, 01 Apr 2019 19:35:22 +0300 Subject: Re: Gigantic load average spikes To: Michel Pelletier , David Rowley Cc: hjp-pgsql@hjp.at, pgsql-general General References: <18b22010-1e6f-9270-e273-b9803fee1498@mail.ru> From: rihad Message-ID: <8472c827-210b-7262-dcef-9c730b14a24c@mail.ru> Date: Mon, 1 Apr 2019 20:35:20 +0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------229572CED476DE8CCFC3823D" Content-Language: en-US Authentication-Results: smtp40.i.mail.ru; auth=pass smtp.auth=rihad@mail.ru smtp.mailfrom=rihad@mail.ru X-77F55803: 0014004E1F3277295A78504BD2AC2941C38C16A539EA0B46802BFCE4CB24962A219689B5F9B197D8B2083563F2D15BC9 X-7FA49CB5: 0D63561A33F958A5B69414604D9B1508E2CEB952259E9603146CDA5096CD25408941B15DA834481FA18204E546F3947CEDCF5861DED71B2F389733CBF5DBD5E9C8A9BA7A39EFB7666BA297DBC24807EA117882F44604297287769387670735209ECD01F8117BC8BEA471835C12D1D977C4224003CC8364767815B9869FA544D8D32BA5DBAC0009BE9E8FC8737B5C2249668B94F0A65C3A0C3AA81AA40904B5D9CF19DD082D7633A0E7DDDDC251EA7DABD81D268191BDAD3D78DA827A17800CE7542AF255F21831B5CD04E86FAF290E2D40A5AABA2AD3711975ECD9A6C639B01B78DA827A17800CE7013C1322956AAD3AB0B13296FC44B97975ECD9A6C639B01B4E70A05D1297E1BBC6867C52282FAC8519DC0BE04022C72727F269C8F02392CD5571747095F342E88FB05168BE4CE3AF X-Mailru-Sender: B19AB4DAF1EA2FB5A9A3D80E7E94E6DCC39CD184FC510A2C84C41E6D735C7B7A1B299102C875D7EEABBFE0CF075BC50BFB559BB5D741EB96004FA9CEFBA991DA3A5DB60FBEB33A8A0DA7A0AF5A3A8387 X-Mras: OK List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------229572CED476DE8CCFC3823D Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 04/01/2019 08:30 PM, Michel Pelletier wrote: > > > On Sun, Mar 31, 2019 at 10:49 PM David Rowley > > > wrote: > > > Perhaps a bunch of processes waiting on the access exclusive lock on > the materialized view being released? > > log_lock_waits might help you if the MV takes more than a second to > refresh, otherwise, you might need to have a look at ungranted locks > in pg_locks and see if the number of locks spikes during the refresh. > > > I think David's got the right idea here.  Like he said, investigate > pg_locks, if it is the refresh materialized view, you can avoid the > problem by doing 'REFRESH MATERIALIZED VIEW CONCURRENTLY'.  You will > need at least one unique index on the table. It is actually refreshed concurrently. > > > -- >  David Rowley http://www.2ndQuadrant.com/ >  PostgreSQL Development, 24x7 Support, Training & Services > > --------------229572CED476DE8CCFC3823D Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
On 04/01/2019 08:30 PM, Michel Pelletier wrote:


On Sun, Mar 31, 2019 at 10:49 PM David Rowley <david.rowley@2ndquadrant.com> wrote:

Perhaps a bunch of processes waiting on the access exclusive lock on
the materialized view being released?

log_lock_waits might help you if the MV takes more than a second to
refresh, otherwise, you might need to have a look at ungranted locks
in pg_locks and see if the number of locks spikes during the refresh.

I think David's got the right idea here.  Like he said, investigate pg_locks, if it is the refresh materialized view, you can avoid the problem by doing 'REFRESH MATERIALIZED VIEW CONCURRENTLY'.  You will need at least one unique index on the table.

It is actually refreshed concurrently.



--
 David Rowley                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services



--------------229572CED476DE8CCFC3823D--