-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incremental view maintenance #280
Conversation
|
4a1c99a
to
61bfb63
Compare
7a06694
to
7c345d8
Compare
7c345d8
to
c34f3e7
Compare
c601e29
to
e393fbc
Compare
e393fbc
to
21474b1
Compare
Hi, I want to see what we changed besides pg's patch, but it's hard to tell as there are separate commits of our own codes. |
21474b1
to
baed6b4
Compare
baed6b4
to
70e19ab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Allow to create Incrementally Maintainable Materialized View (IMMV) by using INCREMENTAL option in CREATE MATERIALIZED VIEW command as follow: CREATE [INCREMANTAL] MATERIALIZED VIEW xxxxx AS SELECT ....;
If this boolean column is true, a relations is Incrementally Maintainable Materialized View (IMMV). This is set when IMMV is created.
Originally, tuplestores of AFTER trigger's transition tables were freed for each query depth. For our IVM implementation, we would like to prolong life of the tuplestores because we have to preserve them for a whole query assuming that some base tables might be changed in some trigger functions.
Add tab completion and meta-command output for IVM.
In this implementation, AFTER triggers are used to collect tuplestores containing transition table contents. When multiple tables are changed, multiple AFTER triggers are invoked, then the final AFTER trigger performs actual update of the matview. In addition, BEFORE triggers are also used to handle global information for view maintenance. To calculate view deltas, we need both pre-state and post-state of base tables. Post-update states are available in AFTER trigger, and pre-update states can be calculated by removing inserted tuples and appending deleted tuples. Insterted tuples are filtered using the snapshot taken before table modiication, and deleted tuples are contained in the old transition table. Incrementally Maintainable Materialized Views (IMMV) can contain duplicated tuples. This patch also allows self-join, simultaneous updates of more than one base table, and multiple updates of the same base table.
Details steps: Step1: export snapshot, trigger data suppose is dR. Step2: calculation delta V, dV = dR ⋈ S Step3: apply delta V, V_new = dV U V Step4: dispatch cleanup Ivm feature that allows materialized views to be updated automatically and incrementally just after a underlying table is modified. You can create an incremental maintainable materialized view (IMMV) by using CREATE INCREMENTAL MATERIALIZED VIEW command. The followings are designed to support in view definition queries: - SELECT ... FROM ... WHERE ..., joins (inner joins, self-joins) - some built-in aggregate functions (count, sum, avg) - GROUP BY clause - DISTINCT clause Restriction: The following are not supported in a view definition: - Outer joins - Aggregates other than above, window functions, HAVING - Sub-queries, CTEs - Set operations (UNION, INTERSECT, EXCEPT) - DISTINCT ON, ORDER BY, LIMIT, OFFSET
70e19ab
to
572ab43
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
closes: #ISSUE_Number
Change logs
background:
Why are the changes needed?
Base on patch v28 from Postgres, here is design code: https://hashdata.feishu.cn/docx/RdS6dND7xotUhLxQi1UctzCVnih
The challenge lies in how to implement IVM in a distributed environment.
Does this PR introduce any user-facing change?
If yes, please clarify the previous behavior and the change this PR proposes.
How was this patch tested?
Add extra test to regress:
Contributor's Checklist
Here are some reminders and checklists before/when submitting your pull request, please check them:
make installcheck
make -C src/test installcheck-cbdb-parallel