pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
avoid WAL for refresh of materialized view
3+ messages / 3 participants
[nested] [flat]

* avoid WAL for refresh of materialized view
@ 2020-03-24 15:59  Remund Alain <alain.remund@bertschi.com>
  0 siblings, 2 replies; 3+ messages in thread

From: Remund Alain @ 2020-03-24 15:59 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

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?

Kind regards,
Alain Remund

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: avoid WAL for refresh of materialized view
@ 2020-03-24 16:03  Guillaume Lelarge <guillaume@lelarge.info>
  parent: Remund Alain <alain.remund@bertschi.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Guillaume Lelarge @ 2020-03-24 16:03 UTC (permalink / raw)
  To: Remund Alain <alain.remund@bertschi.com>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

Le mar. 24 mars 2020 à 17:00, Remund Alain <alain.remund@bertschi.com> a
écrit :

> 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?
>
>
>

As you say, there is no unlogged materialized view. So, no, it will always
log to the WAL during refresh.

>

-- 
Guillaume.

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: avoid WAL for refresh of materialized view
@ 2020-03-24 16:49  Jerry Sievers <gsievers19@comcast.net>
  parent: Remund Alain <alain.remund@bertschi.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Jerry Sievers @ 2020-03-24 16:49 UTC (permalink / raw)
  To: Remund Alain <alain.remund@bertschi.com>; +Cc: pgsql-general\@lists.postgresql.org <pgsql-general@lists.postgresql.org>

Remund Alain <alain.remund@bertschi.com> 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





^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2020-03-24 16:49 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-03-24 15:59 avoid WAL for refresh of materialized view Remund Alain <alain.remund@bertschi.com>
2020-03-24 16:03 ` Guillaume Lelarge <guillaume@lelarge.info>
2020-03-24 16:49 ` Jerry Sievers <gsievers19@comcast.net>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox