pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ravi Krishna <sravikrishna@mail.com>
To: Philip Semanchuk <philip@americanefficient.com>
Cc: Ayub M <hiayub@gmail.com>
Cc: PostgreSQL General <pgsql-general@lists.postgresql.org>
Subject: Re: postgres materialized view refresh performance
Date: Fri, 23 Oct 2020 09:52:01 -0400
Message-ID: <A096D7B4-39AB-486C-A8CF-62240F128D78@mail.com> (raw)
In-Reply-To: <2626DFA9-3446-49D7-A8D7-31EC4863E7D7@americanefficient.com>
References: <CAOS0qEs1FJ6o=kPh80Vk0+i22behSY9VkSHRCknEa2jgGXyJ8Q@mail.gmail.com>
	<2626DFA9-3446-49D7-A8D7-31EC4863E7D7@americanefficient.com>

> My understanding is that when CONCURRENTLY is specified, Postgres implements the refresh as a series of INSERT, UPDATE,
> and DELETE statements on the existing view. So the answer to your question is no, Postgres doesn’t create another table and
> then swap it.

The INSERTS/UPDATE/DELETE happens only for the difference.  PG first creates a new temp table and then compares it with
the MV and detects the difference.  That is why for CONCURRENTLY, a unique index is required on the MV.




view thread (8+ messages)  latest in thread

Message-ID: <A096D7B4-39AB-486C-A8CF-62240F128D78@mail.com>
Permalink:  ../A096D7B4-39AB-486C-A8CF-62240F128D78@mail.com/
Also on:    postgresql.org/message-id/A096D7B4-39AB-486C-A8CF-62240F128D78@mail.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: sravikrishna@mail.com, philip@americanefficient.com, hiayub@gmail.com
  Subject: Re: postgres materialized view refresh performance
  In-Reply-To: <A096D7B4-39AB-486C-A8CF-62240F128D78@mail.com>
  References: <CAOS0qEs1FJ6o=kPh80Vk0+i22behSY9VkSHRCknEa2jgGXyJ8Q@mail.gmail.com> <2626DFA9-3446-49D7-A8D7-31EC4863E7D7@americanefficient.com> <A096D7B4-39AB-486C-A8CF-62240F128D78@mail.com>

* 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