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
{{ message }}
Repository navigation
[Roadmap] Support multi table materialized view #7503
changed the title [-]多表物化视图Doris 当前的 "物化视图" 更偏向 "物化索引" 的概念。后续 Doris 将实现真正的物化视图(Materialized View)以支持单表、多表视图的全量、增量构建。[/-][+][Proposal] Support multi table materialized view[/+]on Dec 31, 2021
At present, materialized views can be created on a single table, and can use pre-computed results to achieve query acceleration, but support for multi-table scenarios cannot be realized. Many query scenarios are relatively simple and the data update frequency is not high. Materialized views can effectively improve query performance and reduce data calculation
Competitors
Both traditional TP database ORACLE and emerging AP database CK are supported
create materialized view mv_name -- 1. Create a materialized view
build [immediate | deferred] -- 2. Create method, default immediate
refresh [fast | complete | never] -- 3. Refresh method of materialized view,on [commit | demand] -- 4. Refresh trigger method
start with start_time -- 5. Set the start time
next interval -- 6. Set the interval time
PARTITION BY [range|list] -- 7. Set the partition column
DISTRIBUTED BY hash(cols..) BUCKETS 16-- 8. Set up buckets
PROPERTIES() -- 9. propertiesas-- 10. Keywordsselect ...; -- 11. select statement
explain
1. "build"-- how to create
(1) 'immediate': Take effect immediately, default.
(2) 'deferred' : Delay until the first refresh to take effect
2. "refresh" refresh method
(1) fast : 'Fast refresh'. Incremental refresh
(2) complete: 'complete refresh'. Update all data when refreshing, including the original data that has been generated in the view
(3) never : never refresh
3. "on" trigger mode (On demand, only need to set'start time'and'interval time')
(1) oncommit: When the base table has a commit action, refresh the map ("Cannot execute across databases")
(2) on demand: refresh when needed
[1] Refresh according to the 'start time'and'end time'set later
[2] Manual call to refresh
DESC
DESCRIBE test_mv_view;
SHOW CREATE
SHOW CREATE MATERIALIZED VIEW test_mv_view;
DROP
DROP MATERIALIZED VIEW test_mv_view;
ALTER
alter materialized view name
refresh [fast | complete | never]
on [commit | demand]
start with start time
next interval
Optional Automatically hit multi-table materialized views
design
Create
A multi-table materialized view exists as a special type of table. It is essentially a table. All management is the same as a table, but it cannot be updated or imported. It is the same as view in display.
Multi-table materialized view information is recorded in the information_schema library table
The table structure is as follows
+----------------------+------------+------+-------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------------+------------+------+-------+---------+-------+
| TABLE_CATALOG | VARCHAR(*) | Yes | false | NULL | |
| TABLE_SCHEMA | VARCHAR(*) | Yes | false | NULL | |
| TABLE_NAME | VARCHAR(*) | Yes | false | NULL | |
| VIEW_DEFINITION | VARCHAR(*) | Yes | false | NULL | |
| CHECK_OPTION | VARCHAR(*) | Yes | false | NULL | |
| IS_UPDATABLE | VARCHAR(*) | Yes | false | NULL | |
| DEFINER | VARCHAR(*) | Yes | false | NULL | |
| SECURITY_TYPE | VARCHAR(*) | Yes | false | NULL | |
| CHARACTER_SET_CLIENT | VARCHAR(*) | Yes | false | NULL | |
| COLLATION_CONNECTION | VARCHAR(*) | Yes | false | NULL | |
| STATUS | VARCHAR(*) | Yes | false | NULL | |
+----------------------+------------+------+-------+---------+-------+
The STATUS field represents the current state of the materialized view, and the optional value [Syncing|OutDate|UpToDate|Never|Error] checks the data update state of the materialized view during display
refresh
According to the refresh strategy, data is imported or refreshed periodically. If the data is not up-to-date, it will be updated according to the conditions, and the command to refresh the data will be issued at the same time, and it will be converted into a normal view query. You can also refresh manually. The refresh command is essentially insert into select, which is completed in the background. At the same time, change the STATUS in materialized_views to Syncing, and change it to UpToDate after synchronization is complete.
alter
When performing schema change on a table, it is necessary to judge the impact and whether it is necessary to update the multi-table materialized view
query
Multi-table materialized views can be directly queried and automatically hit if possible
other
Multi-table materialized views are not suitable for frequently updated tables when updated on commit
Oh, I mean if I update/insert/delete the base table, the mv can be updated automatically? Is it an incremental update, or fully rebuild?
2. "refresh" refresh method
(1) fast : 'Fast refresh'. Incremental refresh
(2) complete: 'complete refresh'. Update all data when refreshing, including the original data that has been generated in the view
(3) never : never refresh
Incremental updates and automatic hits may not be possible in the short term and can be used as future optimization goals
Activity
[-]多表物化视图Doris 当前的 "物化视图" 更偏向 "物化索引" 的概念。后续 Doris 将实现真正的物化视图(Materialized View)以支持单表、多表视图的全量、增量构建。[/-][+][Proposal] Support multi table materialized view[/+][-][Proposal] Support multi table materialized view[/-][+][Roadmap] Support multi table materialized view[/+]yangzhg commentedon Jun 17, 2022
Background
At present, materialized views can be created on a single table, and can use pre-computed results to achieve query acceleration, but support for multi-table scenarios cannot be realized. Many query scenarios are relatively simple and the data update frequency is not high. Materialized views can effectively improve query performance and reduce data calculation
Competitors
Both traditional TP database ORACLE and emerging AP database CK are supported
oracle https://docs.oracle.com/cd/E11882_01/server.112/e10706/repmview.htm#REPLN003,
CK https://clickhouse.com/docs/en/sql-reference/statements/create/view
grammar
Create
The syntax refers to oracle design
explain
DESC
SHOW CREATE
DROP
ALTER
refresh
query
Optional Automatically hit multi-table materialized views
design
Create
A multi-table materialized view exists as a special type of table. It is essentially a table. All management is the same as a table, but it cannot be updated or imported. It is the same as view in display.
Multi-table materialized view information is recorded in the information_schema library table
The table structure is as follows
refresh
According to the refresh strategy, data is imported or refreshed periodically. If the data is not up-to-date, it will be updated according to the conditions, and the command to refresh the data will be issued at the same time, and it will be converted into a normal view query. You can also refresh manually. The refresh command is essentially insert into select, which is completed in the background. At the same time, change the STATUS in materialized_views to
Syncing, and change it to UpToDate after synchronization is complete.alter
When performing schema change on a table, it is necessary to judge the impact and whether it is necessary to update the multi-table materialized view
query
other
yangzhg commentedon Jun 20, 2022
morningman commentedon Jun 20, 2022
Oh, I mean if I update/insert/delete the base table, the mv can be updated automatically? Is it an incremental update, or fully rebuild?
yangzhg commentedon Jun 20, 2022
Incremental updates and automatic hits may not be possible in the short term and can be used as future optimization goals
yangzhg commentedon Jun 20, 2022
缘起
现在物化视图能够支持在单表上创建,能够使用预计算的结果实现查询加速,但是对于多表场景的支持还不能实现,很多查询场景比较单一,数据更新频率不高的情况下,多表的物化视图能够有效的提升查询性能,减少数据的计算
竞品
传统TP数据库ORACLE 和新兴AP数据库 CK 都支持
oracle https://docs.oracle.com/cd/E11882_01/server.112/e10706/repmview.htm#REPLN003、
CK https://clickhouse.com/docs/en/sql-reference/statements/create/view
语法
创建
语法参照oracle 设计
解释
DESC
SHOW CREATE
DROP
ALTER
刷新
查询
可选 自动命中多表物化视图
实现
创建
多表物化视图作为一种特殊类型表存在,本质上是一张表,所有管理和表一样,但是无法更新,无法导入, 在显示上和view 相同
多表物化视图信息记录在 information_schema 库中 表中
表结构如下
更新
根据刷新策略,在数据导入或者定时刷新数据。 如果数据不是最新的则根据条件更新,发出刷新数据命令同时转换成普通视图查询。也可以手动刷新,刷新命令本质上是 insert into select ,在后台完成,同时将materialized_views 中STATUS改成
Syncing,同步完成后改成UpToDate更改
在对表进行schema chang 时需要判断影响,是否需要更新多表物化视图
查询
其他
BiteTheDDDDt commentedon Jun 21, 2022
Can we think that this is a new mv that is not related to the original single-table mv?
yangzhg commentedon Jun 22, 2022
I think so, single-table mv more like an index
voyagertanyao commentedon Sep 20, 2022
弱弱的问一下,物化视图增强版什么时候可以发布呢?目前我们在调研doris 1.1.1,用起来感觉这个功能限制实在是太多了,不是特别好用,本想用这个功能替换kylin的,目前感觉这个物化视图功能还不够完善;