pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Wells Oliver <wells.oliver@gmail.com>
To: pgsql-admin <pgsql-admin@postgresql.org>
Subject: Re: Materialized views & dead tuples
Date: Wed, 19 Jun 2024 09:27:27 +0200
Message-ID: <776e98bc5ded6b4cda83d1d5318f4186e4f8e344.camel@cybertec.at> (raw)
In-Reply-To: <CAOC+FBU1d_VXbWsx6fNXaANQCKD0SRLB4Tupm4dC-7JiU5rdhg@mail.gmail.com>
References: <CAOC+FBU1d_VXbWsx6fNXaANQCKD0SRLB4Tupm4dC-7JiU5rdhg@mail.gmail.com>

On Tue, 2024-06-18 at 15:28 -0700, Wells Oliver wrote:
> Apologies for the daft question, but I am surprised to see materialized views
> show up in pg_stat_user_tables with lots of dead tuples. These are rematerialized
> nightly and, I thought, this had the effect of replacing/recreating them anew.
> Can someone shed some light on this?

It makes a difference if you use REFRESH MATERIALIZED VIEW or
REFRESH MATERIALIZED VIEW CONCURRENTLY.

The first statement will just discard the materialized table and create it anew,
and you will never see a dead tuple.
The second statement executes the query and updates the materialized table, which
can lead to dead tuples just like a normal UPDATE or DELETE.

Yours,
Laurenz Albe





view thread (5+ messages)  latest in thread

Message-ID: <776e98bc5ded6b4cda83d1d5318f4186e4f8e344.camel@cybertec.at>
Permalink:  ../776e98bc5ded6b4cda83d1d5318f4186e4f8e344.camel@cybertec.at/
Also on:    postgresql.org/message-id/776e98bc5ded6b4cda83d1d5318f4186e4f8e344.camel@cybertec.at

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: laurenz.albe@cybertec.at, wells.oliver@gmail.com
  Subject: Re: Materialized views & dead tuples
  In-Reply-To: <776e98bc5ded6b4cda83d1d5318f4186e4f8e344.camel@cybertec.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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