pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: John R Pierce <pierce@hogranch.com>
To: pgsql-general@postgresql.org
Subject: Re: Incremental refresh - Materialized view
Date: Tue, 7 Nov 2017 10:07:40 -0800
Message-ID: <1068317d-dc30-d9bc-1f2f-c8ea841f99dc@hogranch.com> (raw)
In-Reply-To: <CAP7eca1jK1KoL0qk+tT7YOrAcjsJWvsjE7R6vKpnoYEbWEwbWA@mail.gmail.com>
References: <CAP7eca1EGAArdhRcGghi96+gkxpwx7Sx-ybjWp+3zdurasG=0A@mail.gmail.com>
	<CAP7eca1VUUCLquqSU7WZ-+fJc13iX0LHphH4C+4kDc5KeLXvnw@mail.gmail.com>
	<CAP7eca0Ww7nW7YM2xBXecu_7VsX0+TmjqNifVzmds=pJWcahoQ@mail.gmail.com>
	<c596bb74-85ea-d000-349c-a2a67cc1549b@hogranch.com>
	<CAP7eca1jK1KoL0qk+tT7YOrAcjsJWvsjE7R6vKpnoYEbWEwbWA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-general>

On 11/6/2017 11:34 PM, Krithika Venkatesh wrote:
> Materialized view log is one of the feature in oracle. It creates a 
> log in which the changes made to the table are recorded. This log is 
> required for an asynchronous materialized view that is refreshed 
> incrementally.
>
> I read in the below link about incrementally refreshing the 
> materialized view in postgresql:
>
> https://medium.com/@hariprasathnallsamy/postgresql-materialized-view-incremental-refresh-44d1ca74259...
>
> Can someone let me how to do incremental refresh using Write Ahead Log


I note that bloggers sample code on github no longer exists.m   I 
suspect it was half baked, and ran into intractable problems.

to do what you want, you would need to implement logical decoding [1] of 
the WAL stream,  you would need to 'understand' the views completely so 
you can tell if a given tuple update affects one of your views or not 
(relatively simple for a view which is just `select fields from table 
where simplecondition`, not so easy for a view which is a N way join 
with complex filtering and/or aggregation, or whatever), then accumulate 
these updates somewhere so your incremental refresh could replay them 
and update the table underlying a given materialized view.

I'm sure i'm not thinking of major aspects complicating this.


[1] 
https://www.postgresql.org/docs/current/static/logicaldecoding-explanation.html



-- 
john r pierce, recycling bits in santa cruz



-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



view thread (8+ messages)  latest in thread

Message-ID: <1068317d-dc30-d9bc-1f2f-c8ea841f99dc@hogranch.com>
Permalink:  ../1068317d-dc30-d9bc-1f2f-c8ea841f99dc@hogranch.com/
Also on:    postgresql.org/message-id/1068317d-dc30-d9bc-1f2f-c8ea841f99dc@hogranch.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: pierce@hogranch.com
  Subject: Re: Incremental refresh - Materialized view
  In-Reply-To: <1068317d-dc30-d9bc-1f2f-c8ea841f99dc@hogranch.com>
  References: <CAP7eca1EGAArdhRcGghi96+gkxpwx7Sx-ybjWp+3zdurasG=0A@mail.gmail.com> <CAP7eca1VUUCLquqSU7WZ-+fJc13iX0LHphH4C+4kDc5KeLXvnw@mail.gmail.com> <CAP7eca0Ww7nW7YM2xBXecu_7VsX0+TmjqNifVzmds=pJWcahoQ@mail.gmail.com> <c596bb74-85ea-d000-349c-a2a67cc1549b@hogranch.com> <CAP7eca1jK1KoL0qk+tT7YOrAcjsJWvsjE7R6vKpnoYEbWEwbWA@mail.gmail.com> <1068317d-dc30-d9bc-1f2f-c8ea841f99dc@hogranch.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