前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >构建物化视图的两种方式

构建物化视图的两种方式

作者头像
ImportSource
发布2018-05-04 10:46:56
8880
发布2018-05-04 10:46:56
举报
文章被收录于专栏:ImportSource

构建物化视图的两种方式

章节:nosql distilled 第三章第四节 物化视图

There are two rough strategies to building a materialized view. The first is the eager approach where you update the materialized view at the same time you update the base data for it.

现在啊,我们有两种略显粗糙的办法来构建一个物化视图。

第一种是一种即时的方式,就是一旦基础数据更新了马上就去更新物化视图。

In this case, adding an order would also update the purchase history aggregates for each product.

在这种情况下,添加一条订单也会为每个产品更新购买历史纪录的那个聚合(也就是那个物化视图)。

This approach is good when you have more frequent reads of the materialized view than you have writes and you want the materialized views to be as fresh as possible.

这个方法非常适合哪种在你读取操作比写入操作频繁并且你希望那个物化视图的数据尽可能是最新的数据。在这种情况下,这种即时构建的方法很适合。

The application database (p. 7) approach is valuable here as it makes it easier to ensure that any updates to base data also update materialized views.

像应用数据库的解决方案就是非常适合这种情况。因为它可以很容易的确保当原始数据更新的时候,物化视图也会同时被更新。

If you don’t want to pay that overhead on each update, you can run batch jobs to update the materialized views at regular intervals. You’ll need to understand your business requirements to assess how stale your materialized views can be.

如果你不想在每次更新基础数据的时候就去更新物化视图,你可以运行一个批处理任务定时去更新你的物化视图。但你得先去看看你的具体业务需求中对于物化视图的新鲜程度的要求,然后再来确定隔好久更新一次。

You can build materialized views outside of the database by reading the data, computing the view, and saving it back to the database.

你可以在数据库之外构建物化视图:先读取数据,然后计算出结果,最后把结果保存进数据库。

More often databases will support building materialized views themselves. In this case, you provide the computation that needs to be done, and the database executes the computation when needed according to some parameters that you configure. This is particularly handy for eager updates of views with incremental map-reduce (“ Incremental Map- Reduce,” p. 76).

大部分的数据库都支持内部构建物化视图。在这种情况下,你告诉数据库需要做哪些计算,然后数据库会在需要的时候根据你配置好的参数进行计算。这个对于使用增量式maprduce来即时更新视图的情况非常方便。

Materialized views can be used within the same aggregate.

An order document might include an order summary element that provides summary information about the order so that a query for an order summary does not have to transfer the entire order document.

Using different column families for materialized views is a common feature of column-family databases.

An advantage of doing this is that it allows you to update the materialized view within the same atomic operation.

物化视图也可以在同一个聚合内使用。一个订单文档中可能包含那种为订单提供摘要信息的element(就是文档中有个element)。所以呢,当你去查询有关订单摘要信息的时候,数据库并不会transfer(穿越)整个订单的这个dom。

为不同的列族来构建物化视图是一个列族数据库们的常用功能,也就是标配。

这么做的好处就是你更新物化视图的时候具备了事务能力,其实就是那个ACID啦。

好啦,这就是我们今天的内容!

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2016-04-19,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 ImportSource 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
数据库
云数据库为企业提供了完善的关系型数据库、非关系型数据库、分析型数据库和数据库生态工具。您可以通过产品选择和组合搭建,轻松实现高可靠、高可用性、高性能等数据库需求。云数据库服务也可大幅减少您的运维工作量,更专注于业务发展,让企业一站式享受数据上云及分布式架构的技术红利!
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档