Closed yugo-n closed 4 years ago
Upcoming OUTER JOIN support will remove this limitation.
Yes. It is because OUTER JOIN can generate tuple including NULL and IVM have to handle this correctly.
I will also add this test case to the regression test when making the patch for outer-join.
I found remaining problem with aggregate views. I will fix this.
=# create table t (i int, v int);
CREATE TABLE
=# insert into t values (null, 1), (null, 2);
INSERT 0 2
=# create incremental materialized view mv as select i, sum(v) from t group by i;
SELECT 1
=# select * from mv;
i | sum
---+-----
| 3
(1 row)
=# update t set v = v*10;
UPDATE 2
=# select * from mv;
i | sum
---+-----
| 3
| 30
(2 rows)
During fixing this, I found another issue in IMMVs without aggregate.
null=# \d x
Table "public.x"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
i | integer | | |
Indexes:
"x_i_idx" btree (i)
null=# \d+ v
Materialized view "public.v"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
---------------+---------+-----------+----------+---------+---------+--------------+-------------
i | integer | | | | plain | |
__ivm_count__ | bigint | | | | plain | |
Indexes:
"v_i_idx" btree (i)
View definition:
SELECT x.i
FROM x;
Access method: heap
Incremental view maintenance: yes
null=# insert into x values (1),(null);
INSERT 0 2
null=# select * from v;
i
---
(0 rows)
This is due to NOT IN behaviour involving NULL value. I'll fix this, too.
This is fixed by the above commit.