Skip to content

Commit d02a01d

Browse files
committed
[AQUMV] Use view's TupleDesc to construct final columns.
We once used a SQL like: SELECT * FROM mv to fetch target materialized view's attributes, which is ineffective. Use TupleDesc to fetch mv's attributes instead. Authored-by: Zhang Mingli avamingli@gmail.com
1 parent 5440d5a commit d02a01d

2 files changed

Lines changed: 99 additions & 149 deletions

File tree

src/backend/optimizer/README.cbdb.aqumv

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ A materialized view(MV) could be use to compute a Query if:
3030

3131
Vocabulary:
3232
origin_query: the SQL we want to query.
33-
mv_query: for materialized view's corresponding query, the SELECT part of a Create Materialized View.
33+
view_query: the materialized view's corresponding query, SELECT part of Create Materialized View statement.
3434

3535
Construct Rows
3636
--------------
@@ -39,7 +39,7 @@ If MV has all rows of query needed, it means that MV query's restrictions are lo
3939
For AQUMV_MVP0, we only do logistic transformation.
4040
All rewrites are on the Query tree, neither Equivalent Classes nor Restrictions are used.
4141
For a single relation:
42-
process mv_query and origin_query's WHERE part to set:
42+
process view_query and origin_query's WHERE part to set:
4343
mv_query_quals and origin_query_quals.
4444

4545
example0:
@@ -134,14 +134,14 @@ mv5 has all rows {a = 1} and only have column 'a', but the query want additional
134134
We couldn't rewrite it by just adding the {b = 2} to MV as no equivalent b in MV relation.
135135
Wrong: SELECT a FROM mv5 WHERE b = 2;
136136

137-
The algorithm behind that is: all quals's expression could be computed from a mv_query's target list.
137+
The algorithm behind that is: all quals's expression could be computed from a view_query's target list.
138138
That's what Construct Columns does.
139139

140140
Construct Columns
141141
-----------------
142142

143143
A MV could be a candidate if the query's target list and the post_quals could be computed form
144-
mv_query's target list and rewrite to expressions bases on MV relation's columns itself.
144+
view_query's target list and rewrite to expressions bases on MV relation's columns itself.
145145

146146
example6:
147147
CREATE MATERIALIZED VIEW mv6 AS SELECT abs(c) as mc1, b as mc2 FROM t WHERE a = 1;
@@ -218,13 +218,13 @@ Let the planner decide the best one.
218218

219219
AQUMV_MVP
220220
---------
221-
Support SELECT FROM a single relation both for mv_query and the origin_query.
221+
Support SELECT FROM a single relation both for view_query and the origin_query.
222222
Below are not supported now:
223-
Aggregation (on mv_query)
223+
Aggregation (on view_query)
224224
Subquery
225225
Join
226226
Sublink
227-
Group By/Grouping Sets/Rollup/Cube (on mv_query)
227+
Group By/Grouping Sets/Rollup/Cube (on view_query)
228228
Window Functions
229229
CTE
230230
Distinct

0 commit comments

Comments
 (0)