From alain.remund@bertschi.com Tue Mar 24 15:59:46 2020 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.92) (envelope-from ) id 1jGlz5-0006x4-5F for pgsql-general@arkaria.postgresql.org; Tue, 24 Mar 2020 16:00:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jGly5-0006A5-OY for pgsql-general@arkaria.postgresql.org; Tue, 24 Mar 2020 15:59:53 +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 1jGly5-00068u-BE for pgsql-general@lists.postgresql.org; Tue, 24 Mar 2020 15:59:53 +0000 Received: from mail.bertschi.com ([194.147.70.69]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jGly1-0005NL-W1 for pgsql-general@lists.postgresql.org; Tue, 24 Mar 2020 15:59:52 +0000 Received: from mail.bertschi.com ([172.20.32.162]) by mail.bertschi.com with ESMTP id 02OFxlf6024920-02OFxlf8024920 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=OK) for ; Tue, 24 Mar 2020 16:59:47 +0100 Received: from dueexs11.bertschi.domain (172.20.32.161) by dueexs21.bertschi.domain (172.20.32.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Tue, 24 Mar 2020 16:59:47 +0100 Received: from dueexs11.bertschi.domain ([fe80::e4c2:7a17:4a03:74f5]) by dueexs11.bertschi.domain ([fe80::e4c2:7a17:4a03:74f5%14]) with mapi id 15.01.1847.003; Tue, 24 Mar 2020 16:59:46 +0100 From: Remund Alain To: "pgsql-general@lists.postgresql.org" Subject: avoid WAL for refresh of materialized view Thread-Topic: avoid WAL for refresh of materialized view Thread-Index: AdYB9Sbjnkh7mixhQzGwX5HhV0fToQ== Date: Tue, 24 Mar 2020 15:59:46 +0000 Message-ID: Accept-Language: de-CH, en-US Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.20.32.203] Content-Type: multipart/alternative; boundary="_000_e6b0ccfe181f45868304015db4029746bertschicom_" MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --_000_e6b0ccfe181f45868304015db4029746bertschicom_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi all We have PostgreSql 9.6 running and started to work with materialized views.= To refresh the materialized views, we set up a cron job that refreshes the= materialized views on a fix schedule. Since our materialized views cache quite some data, we noticed a considerab= le increase in WAL files. It seems, that every refresh of a materialized vi= ew is logged in the WAL. We tried to figure out how we can alter the materialized view to set it to = "UNLOGGED" but this does not seem possible. --> "alter materialized view xyz set UNLOGGED;" leads to "ERROR: "xyz" is = not a table, SQL state: 42809" Is there another way to avoid logging a refresh of a materialized view in t= he WAL? Kind regards, Alain Remund --_000_e6b0ccfe181f45868304015db4029746bertschicom_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi all

 

We have PostgreSql 9.6 running and started to work w= ith materialized views. To refresh the materialized views, we set up a cron= job that refreshes the materialized views on a fix schedule.

Since our materialized views cache quite some data, = we noticed a considerable increase in WAL files. It seems, that every refre= sh of a materialized view is logged in the WAL.

 

We tried to figure out how we can alter the material= ized view to set it to "UNLOGGED" but this does not seem possible= .

--> "alter materialized view xyz set UNLOGGE= D;" leads to "ERROR:  "xyz" is not a table, SQL st= ate: 42809"

 

Is there another way to avoid logging a refresh of a= materialized view in the WAL?

 

Kind regards,

Alain Remund

--_000_e6b0ccfe181f45868304015db4029746bertschicom_-- From guillaume@lelarge.info Tue Mar 24 16:03:42 2020 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.92) (envelope-from ) id 1jGm22-00072c-W5 for pgsql-general@arkaria.postgresql.org; Tue, 24 Mar 2020 16:03:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jGm21-00050x-LU for pgsql-general@arkaria.postgresql.org; Tue, 24 Mar 2020 16:03:57 +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 1jGm21-0004wK-4p for pgsql-general@lists.postgresql.org; Tue, 24 Mar 2020 16:03:57 +0000 Received: from mail-ot1-x329.google.com ([2607:f8b0:4864:20::329]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jGm1y-0005PT-6B for pgsql-general@lists.postgresql.org; Tue, 24 Mar 2020 16:03:55 +0000 Received: by mail-ot1-x329.google.com with SMTP id s18so7957950otr.9 for ; Tue, 24 Mar 2020 09:03:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lelarge-info.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kzZdaZc5pk3UU8+Q8KqopriuMm3UrdiYqT2QJwyUD8U=; b=a7rl7IprQl1Mep8fNAsedwchXIxIlONj31fARM1nWZVwKlOGylAwWlNjjC3ljM/+7W omh8DNrCmb1pdauXytyvLRqNq+rz9lidcOM2yBVVV38RVESSReCwXrZELrCzNEoFX6KA y25RjTR3BVVuVa/ynIdHhdNPcVE+japEiZnaQa20QPmsm1hT99rQ1MIyvsruUst+I1nF 3OyAsHHkZ4Bfs3qUMuv6yqr3t2JVj42kJJudJeDS7ubhdhoOi5KxvBE/oUFqzyheR1kF 5ARk1oPUSDdJD3aRioLGUY572nQ0h/juPZzQd9ZLtSREO0v68hEAf15iHTRfs4roxGw+ xmew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kzZdaZc5pk3UU8+Q8KqopriuMm3UrdiYqT2QJwyUD8U=; b=ef5QIV5p7j0wmTRPWCUrAH9ZpTz1Rw4WGabaLHGNty54yJbMNaWXLLvqM20NWu9Jwn BL4mcfioPHgZf/V4VTClN5dDtLHg/+pZsS0jiiZ2RfOH2NwQ1UwzszJuUBUy/xN4sjIm CUpSAfqWcNrQ6H2UjX4W20qX7fGM3vBwTo4XgmjGEuNxqZAphv01+IaM/+Of4BpHDEGE iGO9gRYoHL8sxKd7dfwsE16aQ/7q7QMs1+JSdHFkanXZcOoermcWzBr+hAL/Pb6j1/wd ydhtMy27zEMIKj8gR4hMqkdXu1+WYlPZu+gR+4TVsoXWe+RBbThDFwfGL1Og3mrVLtSy reXQ== X-Gm-Message-State: ANhLgQ0AX0AqF92POjxB4wiBHLYA1cWARzi+L1bh8cRjOcf8OG5IL8vH MpXkJfzkx5X42V49FtAONj513ifV8ST2W1Yp4FF2Kg== X-Google-Smtp-Source: ADFU+vsA1TC45OcKuOtuZFlG2dAaC4dfKN+RaShE6IkAQ4HhPpbtx92Xy2gBBIubX1/6tr9J5DUvZZdMBZcN0ujyL+E= X-Received: by 2002:a4a:4cc1:: with SMTP id a184mr2190384oob.72.1585065832877; Tue, 24 Mar 2020 09:03:52 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Guillaume Lelarge Date: Tue, 24 Mar 2020 17:03:42 +0100 Message-ID: Subject: Re: avoid WAL for refresh of materialized view To: Remund Alain Cc: "pgsql-general@lists.postgresql.org" Content-Type: multipart/alternative; boundary="000000000000ea230905a19be547" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --000000000000ea230905a19be547 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Le mar. 24 mars 2020 =C3=A0 17:00, Remund Alain = a =C3=A9crit : > Hi all > > > > We have PostgreSql 9.6 running and started to work with materialized > views. To refresh the materialized views, we set up a cron job that > refreshes the materialized views on a fix schedule. > > Since our materialized views cache quite some data, we noticed a > considerable increase in WAL files. It seems, that every refresh of a > materialized view is logged in the WAL. > > > > We tried to figure out how we can alter the materialized view to set it t= o > "UNLOGGED" but this does not seem possible. > > --> "alter materialized view xyz set UNLOGGED;" leads to "ERROR: "xyz" i= s > not a table, SQL state: 42809" > > > > Is there another way to avoid logging a refresh of a materialized view in > the WAL? > > > As you say, there is no unlogged materialized view. So, no, it will always log to the WAL during refresh. > --=20 Guillaume. --000000000000ea230905a19be547 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Le=C2=A0mar. 24 mars 2020 =C3=A0=C2=A017:00, Remund Alain <alain.remund@bertschi.com> a = =C3=A9crit=C2=A0:

Hi all

=C2=A0

We have PostgreSql 9.6 running and started to work w= ith materialized views. To refresh the materialized views, we set up a cron= job that refreshes the materialized views on a fix schedule.=

Since our materialized views cache quite some data, = we noticed a considerable increase in WAL files. It seems, that every refre= sh of a materialized view is logged in the WAL.

=C2=A0

We tried to figure out how we can alter the material= ized view to set it to "UNLOGGED" but this does not seem possible= .

--> "alter materialized view xyz set UNLOGGE= D;" leads to "ERROR:=C2=A0 "xyz" is not a table, SQL st= ate: 42809"

=C2=A0

Is there another way to avoid logging a refresh of a= materialized view in the WAL?

=C2=A0


<= /div>
As you say, there is no unlogged materialized view. So, no, it wi= ll always log to the WAL during refresh.


--
Guillaume.
<= /div>
--000000000000ea230905a19be547-- From gsievers19@comcast.net Tue Mar 24 16:49:24 2020 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.92) (envelope-from ) id 1jGmkN-0000Ge-IV for pgsql-general@arkaria.postgresql.org; Tue, 24 Mar 2020 16:49:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jGmkK-0004lW-JH for pgsql-general@arkaria.postgresql.org; Tue, 24 Mar 2020 16:49:44 +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 1jGmkJ-0004lO-Sl for pgsql-general@lists.postgresql.org; Tue, 24 Mar 2020 16:49:44 +0000 Received: from resqmta-ch2-09v.sys.comcast.net ([2001:558:fe21:29:69:252:207:41]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jGmkG-0005jI-2k for pgsql-general@lists.postgresql.org; Tue, 24 Mar 2020 16:49:43 +0000 Received: from resomta-ch2-15v.sys.comcast.net ([69.252.207.111]) by resqmta-ch2-09v.sys.comcast.net with ESMTP id GmKGjC6HrdWWZGmkAjcN4N; Tue, 24 Mar 2020 16:49:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=20190202a; t=1585068574; bh=njRj0RqVV8gfp4AQVyLh6j6xUABzdaGNGQinSPind/A=; h=Received:Received:Received:From:To:Subject:Date:Message-ID: MIME-Version:Content-Type; b=0P0B6/KxLc3tsBa0iuYPyQwUHtWb773LqS8Ms1+XKgdFPJbtgw1fbKAY/kwRaTPM5 VrA6iLWgt5SbFyt4k9AC30wWcMxzJOHXhUrSHIuraC4e2jwGC8iK4iXacw7eegkB4e ts+t+GitdEPp3LlzsucnBk5lPOWKw5Knx/Oq3s1wPmy5Jpq3Wn9nxb0Z7iBAS6PRls lCM70UJHk4o3CuPMANH9Ya9IaJ6vkFik76i/vX0JnqFEFfx+9inwCl1hm8n/zZ02e6 hr8WQozrhn5NomUZGieL5OWXGObN4SBXM3QPEjHKtxaUmaEhrg/fWAnJwl/EgXqY9b WSTMKp+SYRX/Q== Received: from jsievers.comcast.net ([12.30.159.20]) by resomta-ch2-15v.sys.comcast.net with ESMTPA id Gmk0j2FAZmvz6Gmk1jmg96; Tue, 24 Mar 2020 16:49:32 +0000 X-Xfinity-VAAS: gggruggvucftvghtrhhoucdtuddrgedugedrudehuddgiedvucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuvehomhgtrghsthdqtfgvshhipdfqfgfvpdfpqffurfetoffkrfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufhfffgjkfgfgggtsehttdertddtredtnecuhfhrohhmpeflvghrrhihucfuihgvvhgvrhhsuceoghhsihgvvhgvrhhsudelsegtohhmtggrshhtrdhnvghtqeenucfkphepuddvrdeftddrudehledrvddtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehhvghlohepjhhsihgvvhgvrhhsrdgtohhmtggrshhtrdhnvghtpdhinhgvthepuddvrdeftddrudehledrvddtpdhmrghilhhfrhhomhepghhsihgvvhgvrhhsudelsegtohhmtggrshhtrdhnvghtpdhrtghpthhtoheprghlrghinhdrrhgvmhhunhgusegsvghrthhstghhihdrtghomhdprhgtphhtthhopehpghhsqhhlqdhgvghnvghrrghlsehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-Xfinity-VMeta: sc=-100.00;st=legit Received: from jsievers.enova.com (localhost [127.0.0.1]) by jsievers.comcast.net (Postfix) with ESMTP id 50F9D26005A; Tue, 24 Mar 2020 11:49:24 -0500 (CDT) From: Jerry Sievers To: Remund Alain Cc: "pgsql-general\@lists.postgresql.org" Subject: Re: avoid WAL for refresh of materialized view References: Date: Tue, 24 Mar 2020 11:49:24 -0500 In-Reply-To: (Remund Alain's message of "Tue, 24 Mar 2020 15:59:46 +0000") Message-ID: <87blolsnor.fsf@jsievers.enova.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Remund Alain writes: > Hi all > > > > We have PostgreSql 9.6 running and started to work with materialized > views. To refresh the materialized views, we set up a cron job that > refreshes the materialized views on a fix schedule. > > Since our materialized views cache quite some data, we noticed a > considerable increase in WAL files. It seems, that every refresh of a > materialized view is logged in the WAL. > > > > We tried to figure out how we can alter the materialized view to set > it to "UNLOGGED" but this does not seem possible. > > --> "alter materialized view xyz set UNLOGGED;" leads to "ERROR: > "xyz" is not a table, SQL state: 42809" > > > > Is there another way to avoid logging a refresh of a materialized > view in the WAL? > The workaround for this is to not use mat view at all but instead materialize the output into an unlogged table that you trunc before every refresh. HTH > > > Kind regards, > > Alain Remund > > > -- Jerry Sievers Postgres DBA/Development Consulting e: postgres.consulting@comcast.net