pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Philip Semanchuk <philip@americanefficient.com>
To: Ravi Krishna <sravikrishna@mail.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 10:53:07 -0400
Message-ID: <FE04128F-9905-4917-925B-0BCF6EC70804@americanefficient.com> (raw)
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>



> On Oct 23, 2020, at 9:52 AM, Ravi Krishna <sravikrishna@mail.com> wrote:
> 
>> 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.

Yes, thank you, that’s what I understand too but I expressed it very poorly. 






view thread (8+ messages)  latest in thread

Message-ID: <FE04128F-9905-4917-925B-0BCF6EC70804@americanefficient.com>
Permalink:  ../FE04128F-9905-4917-925B-0BCF6EC70804@americanefficient.com/
Also on:    postgresql.org/message-id/FE04128F-9905-4917-925B-0BCF6EC70804@americanefficient.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: philip@americanefficient.com, sravikrishna@mail.com, hiayub@gmail.com
  Subject: Re: postgres materialized view refresh performance
  In-Reply-To: <FE04128F-9905-4917-925B-0BCF6EC70804@americanefficient.com>
  References: <CAOS0qEs1FJ6o=kPh80Vk0+i22behSY9VkSHRCknEa2jgGXyJ8Q@mail.gmail.com> <2626DFA9-3446-49D7-A8D7-31EC4863E7D7@americanefficient.com> <A096D7B4-39AB-486C-A8CF-62240F128D78@mail.com> <FE04128F-9905-4917-925B-0BCF6EC70804@americanefficient.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