Re: Delta Materialized View Refreshes?

From: Isaac Morland <isaac(dot)morland(at)gmail(dot)com>
To: finzelj(at)gmail(dot)com
Cc: jd(at)rsa(dot)pub, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Delta Materialized View Refreshes?
Date: 2018-09-14 21:12:57
Message-ID: CAMsGm5efZBWdMrW3R54mJaA=Ck0G9mqwH0aeYvtKPWYkw8ccJw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 14 Sep 2018 at 16:26, Jeremy Finzel <finzelj(at)gmail(dot)com> wrote:

>
>> Could you apply something similar using triggers?
>> One question would be how PG would identify changes to existing rows -
>> using the replication facilities to essentially replicate into the view?
>> This would be quite tricky I reckon. Otherwise a change to the underlying
>> table may not propagate correctly to the MV.
>>
>
> That's not what I had in mind. I only mean when REFRESH MATERIALIZED VIEW
> is run, it gathers the results of the view in memory, then instead of
> essentially "wiping and reloading" the table, it would only write the
> differences. So if 90% of the rows would be the same as before the
> refresh, we only update 10% of the rows.
>

On a related note, I've mused about allowing a WHERE clause on REFRESH
MATERIALIZED VIEW. To start with, I imagine limiting it to refer to the
columns of a primary key (which implies that primary key constraints would
have to be allowed). As long as this is done, I think it's pretty clear
what the semantics would have to be, at least as to the new view contents:
the equivalent of DELETE with the WHERE clause, followed by INSERT of the
view expression with the same WHERE clause applied.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2018-09-14 21:30:48 Re: Logical replication to partitioned subscriber
Previous Message Tom Lane 2018-09-14 20:46:26 Re: stat() on Windows might cause error if target file is larger than 4GB