Skip to content

Conversation

@avamingli
Copy link
Contributor

@avamingli avamingli commented May 30, 2024

Fix misc of AQUMV, please review by commits:

Bypass expression has no Vars for view query target.

For expressions have no Vars, we don't need to sort and take
them into account.

Origin query has mutable functions can not use AQUMV.

We have disabled view query has mutable functions, but forget the
origin query.
Mutable functions should be kept in the origin relation.

Example:

  SELECT random() from t1;

Function random() should be projected on t1 itself.

Add case HAVING clause doesn't have column reference.

HAVING quals like: having 2 > 1, the clause without column reference
should be ok in AQUMV.

-- having quals without column reference.
explain(costs off, verbose)
select c1, c3, avg(c2) from aqumv_t4 where c1 > 90 group by (c1, c3) having 2 > 1;
                                    QUERY PLAN                                    
----------------------------------------------------------------------------------
 Gather Motion 3:1  (slice1; segments: 3)
   Output: mc1, mc3, (avg(mc2))
   ->  HashAggregate
         Output: mc1, mc3, avg(mc2)
         Group Key: aqumv_mvt4_0.mc1, aqumv_mvt4_0.mc3
         ->  Seq Scan on public.aqumv_mvt4_0
               Output: mc1, mc2, mc3
 Settings: enable_answer_query_using_materialized_views = 'on', optimizer = 'off'
 Optimizer: Postgres query optimizer
(9 rows)

Expression 2 > 1 is always true if there were tuples form the underlying relations, same for materialized views we use.
So we could just drop things like that.

Use shcema aqumv for tests

avamingli added 4 commits May 30, 2024 16:19
HAVING quals like: having 2 > 1, the clause without column reference
should be ok in AQUMV.

Authored-by: Zhang Mingli [email protected]
We have disabled view query has mutable functions, but forget the
origin query.
Mutable functions should be kept in the origin relation.

Example:
  SELECT random() from t1;

Function random() should be projected on t1 itself.

Authored-by: Zhang Mingli [email protected]
For expressions have no Vars, we don't need to sort and take
them into account.

Authored-by: Zhang Mingli [email protected]
@avamingli avamingli requested review from my-ship-it and yjhjstz June 13, 2024 15:59
@my-ship-it my-ship-it merged commit 357c6aa into apache:main Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants