You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[AQUMV] Allow to use normal materialized views to answer query.
As we have enabled materialized view data status maintenance,
normal materialized views could also be used to answer query
if their data status is up to date.
There is no difference between IVM and normal materialized
views to answer query.
example, compute agg from a normal materialized view:
create table t1(c1 int, c2 int, c3 int) distributed by (c1);
create materialized view normal_mv_t1 as
select c3 as mc3, c1 as mc1 from t1 where c1 > 90;
set enable_answer_query_using_materialized_views = on;
explain(costs off, verbose)
select count(c3) from t1 where c1 > 90;
QUERY PLAN
------------------------------------------------------
Finalize Aggregate
Output: count(mc3)
-> Gather Motion 3:1 (slice1; segments: 3)
Output: (PARTIAL count(mc3))
-> Partial Aggregate
Output: PARTIAL count(mc3)
-> Seq Scan on aqumv.normal_mv_t1
Output: mc3, mc1
Optimizer: Postgres query optimizer
Authored-by: Zhang Mingli avamingli@gmail.com
insert into t1 select i, i+1, i+2 from generate_series(1, 100) i;
994
+
insert into t1 values (91, NULL, 95);
995
+
analyze t1;
996
+
create materialized view normal_mv_t1 as
997
+
select c3 as mc3, c1 as mc1
998
+
from t1 where c1 > 90;
999
+
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'mc1' as the Cloudberry Database data distribution key for this table.
1000
+
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
1001
+
analyze normal_mv_t1;
1002
+
set enable_answer_query_using_materialized_views = off;
0 commit comments