Hi,

Attached is the rebased patch (v18) to add support for Incremental
Materialized View Maintenance (IVM). It is able to be applied to
current latest master branch.

Also, this now supports simple CTEs (WITH clauses) which do not contain
aggregates or DISTINCT like simple sub-queries. This feature is provided
as an additional patch segment "0010-Add-CTE-support-in-IVM.patch".

==== Example ====

cte=# TABLE r;
 i | v  
---+----
 1 | 10
 2 | 20
(2 rows)

cte=# TABLE s;
 i |  v  
---+-----
 2 | 200
 3 | 300
(2 rows)

cte=# \d+ mv
                              Materialized view "public.mv"
 Column |  Type   | Collation | Nullable | Default | Storage | Stats target | 
Description 
--------+---------+-----------+----------+---------+---------+--------------+-------------
 r      | integer |           |          |         | plain   |              | 
 x      | integer |           |          |         | plain   |              | 
View definition:
 WITH x AS (
         SELECT s.i,
            s.v
           FROM s
        )
 SELECT r.v AS r,
    x.v AS x
   FROM r,
    x
  WHERE r.i = x.i;
Access method: heap
Incremental view maintenance: yes

cte=# SELECT * FROM mv;
 r  |  x  
----+-----
 20 | 200
(1 row)

cte=# INSERT INTO r VALUES (3,30);
INSERT 0 1
cte=# INSERT INTO s VALUES (1,100);
INSERT 0 1
cte=# SELECT * FROM mv;
 r  |  x  
----+-----
 20 | 200
 30 | 300
 10 | 100
(3 rows)

======================

Regards,
Yugo Nagata


-- 
Yugo NAGATA <nag...@sraoss.co.jp>

Attachment: IVM_patches_v18.tar.gz
Description: application/gzip

Reply via email to