Fast Filtering for Materialized Views when Answering Query. #1115
Unanswered
avamingli
asked this question in
Ideas / Feature Requests
Replies: 2 comments
-
|
Beta Was this translation helpful? Give feedback.
0 replies
-
part2 #1138 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description
The AQUMV(Answer Query Using Materialized Views) enable us to rewrite queries to select from materialized views/dynamic tables and incremental materialized views.
In scenarios where materialized views are implemented, the query planner must scan through many potential candidates to determine if they can be used to answer the original queries. This process becomes increasingly time-consuming as the number of materialized views grows.
The paper Optimizing Queries Using Materialized Views:A Practical, Scalable Solution discusses how as the number of views increases, the efficiency of query optimization can deteriorate. Specifically, the time taken for query processing can rise significantly, leading to diminishing returns on the benefits that materialized views are supposed to provide.
Efficiently filtering materialized views (MVs) is crucial for optimizing query performance.
As highlighted in the "Fast Filtering of Views" section of the paper:
With 1000 views, the optimization time increases by about 110% when the filter tree is disabled. The pager introduced a Lattice index filter tree to fetch the views.
Recently, we often hear complaints about increased planning time when using AQUMV in scenarios with hundreds of materialized views on a table. Fast filtering for materialized views is essential, and now it’s time to implement it.
Our goal is to design a fast filtering index method inspired by the techniques discussed in the paper. The approach may differ significantly based on the PostgreSQL planner . This index could efficiently narrow down candidate materialized views based on their compatibility with incoming queries, thus minimizing the time spent in the planner.
One immediate area for optimization is that searching for materialized views requires scanning the pg_rewrite table, where the SQL corresponding to the views is stored. PostgreSQL has around 200 built-in rules, which are not user-created for the AQUMV functionality. Even without user-created materialized views, if enable_answer_query_using_materialized_views is turned on, it still requires traversing all pg_rewrite data. Here is an example:
With enable_answer_query_using_materialized_views = off, the planning time is 0.462 ms.
With enable_answer_query_using_materialized_views = on, the planning time increases to 78.942 ms.
As an initial step in the overall plan, this part could be optimized by utilizing other system tables, such as gp_matview_aux, to skip unnecessary scans.
Further details on fast filtering for materialized views will be added.
Use case/motivation
No response
Related issues
No response
Are you willing to submit a PR?
Beta Was this translation helpful? Give feedback.
All reactions