扁平化表格与手动更新
Flattened Tables vs Manual Update
目前我有一个 table (A) 列,其中存储了来自其他 table (B) 的一些聚合值。在 B table 中更改数据时,此列通过普通 UPDATE A ... FROM SELECT B
语句进行相应更新。
Vertica 8.1 提供相关功能:Flattened Tables. With SET USING
constraint it looks like the same process: on demand (by call the REFRESH_COLUMNS()
) 读取源 table 并将结果写入目标列。
Documentation 简单介绍了 Flattened Tables 的好处:
Flattened tables can include columns that get their values by querying other tables. Operations on the source tables and flattened table are decoupled; changes in one are not automatically propagated to the other. This minimizes the overhead that is otherwise typical of denormalized tables.
是的,这个约束看起来比手动更新更清晰。但我只想了解:它只是 "syntax sugar" 在引擎盖下进行相同的操作还是完全不同的方式?它在性能上有什么优点或缺点吗?可能有人已经在使用它并且可以分享自己的经验。
我记录了扁平化表格功能,但那是一段时间以前的事了,所以我与首席开发人员联系以刷新我的记忆。他的回答:
是的,在某些方面,扁平化表格有点类似于 "syntax sugar"。但是,它确实有一些优化使其与众不同。例如,您可以在 UPDATE 模式下使用 SET USING 约束刷新列,从而避免修改未更改的行。此外,没有允许您同时刷新多个列的 DML(至少在 Vertica 中没有)。
目前我有一个 table (A) 列,其中存储了来自其他 table (B) 的一些聚合值。在 B table 中更改数据时,此列通过普通 UPDATE A ... FROM SELECT B
语句进行相应更新。
Vertica 8.1 提供相关功能:Flattened Tables. With SET USING
constraint it looks like the same process: on demand (by call the REFRESH_COLUMNS()
) 读取源 table 并将结果写入目标列。
Documentation 简单介绍了 Flattened Tables 的好处:
Flattened tables can include columns that get their values by querying other tables. Operations on the source tables and flattened table are decoupled; changes in one are not automatically propagated to the other. This minimizes the overhead that is otherwise typical of denormalized tables.
是的,这个约束看起来比手动更新更清晰。但我只想了解:它只是 "syntax sugar" 在引擎盖下进行相同的操作还是完全不同的方式?它在性能上有什么优点或缺点吗?可能有人已经在使用它并且可以分享自己的经验。
我记录了扁平化表格功能,但那是一段时间以前的事了,所以我与首席开发人员联系以刷新我的记忆。他的回答:
是的,在某些方面,扁平化表格有点类似于 "syntax sugar"。但是,它确实有一些优化使其与众不同。例如,您可以在 UPDATE 模式下使用 SET USING 约束刷新列,从而避免修改未更改的行。此外,没有允许您同时刷新多个列的 DML(至少在 Vertica 中没有)。