有人知道 OLAP 内部原理吗?
我对数据库内部结构有所了解。 我之前实际上已经实现了一个小型、简单的关系数据库引擎,使用磁盘上的 ISAM 结构和 BTree 索引以及诸如此类的东西。 这很有趣,而且很有教育意义。 我知道,现在我对 RDBMS 的底层工作原理有了更多的了解,我对仔细设计数据库模式和编写查询有了更多的认识。
但我对多维 OLAP 数据模型一无所知,而且我很难在互联网上找到任何有用的信息。
信息如何存储在磁盘上? 立方体由哪些数据结构组成? 如果 MOLAP 模型不使用带有列和记录的表,那么......怎么办? 尤其是在高维数据中,什么样的数据结构使得MOLAP模型如此高效? MOLAP 实现是否使用类似于 RDBMS 索引的东西?
为什么 OLAP 服务器在处理即席查询方面表现得如此出色? 在普通关系数据库中可能需要数小时才能处理的同类聚合,在 OLTP 多维数据集中只需几毫秒即可处理。 使这成为可能的模型的基本机制是什么?
I know a bit about database internals. I've actually implemented a small, simple relational database engine before, using ISAM structures on disk and BTree indexes and all that sort of thing. It was fun, and very educational. I know that I'm much more cognizant about carefully designing database schemas and writing queries now that I know a little bit more about how RDBMSs work under the hood.
But I don't know anything about multidimensional OLAP data models, and I've had a hard time finding any useful information on the internet.
How is the information stored on disk? What data structures comprise the cube? If a MOLAP model doesn't use tables, with columns and records, then... what? Especially in highly dimensional data, what kinds of data structures make the MOLAP model so efficient? Do MOLAP implementations use something analogous to RDBMS indexes?
Why are OLAP servers so much better at processing ad hoc queries? The same sorts of aggregations that might take hours to process in an ordinary relational database can be processed in milliseconds in an OLTP cube. What are the underlying mechanics of the model that make that possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经实现了几个模仿 OLAP 多维数据集功能的系统,以下是我们为使它们正常工作而所做的一些事情。
核心数据保存在一个 n 维数组中,全部位于内存中,所有键都是通过指向底层数组的指针层次结构来实现的。 通过这种方式,我们可以为相同的数据拥有多个不同的键集。 数组中的数据相当于事实表,通常它只有几条数据,在一个例子中是价格和销售数量。
底层数组通常是稀疏的,因此一旦创建它,我们就会删除所有空白单元以节省内存 - 大量的硬核指针算术,但它有效。
由于我们有键的层次结构,因此我们可以很容易地编写例程来轻松地向下/向上钻取层次结构。 例如,我们可以通过月份键来访问年份数据,而月份键又映射到天和/或周。 在每个级别,我们都会聚合数据作为构建多维数据集的一部分 - 使计算速度更快。
我们没有实现任何类型的查询语言,但我们确实支持在所有轴上向下钻取(在我们最大的立方体中最多 7 个),并且这与用户喜欢的 UI 直接相关。
我们在 C++ 中实现了核心内容,但现在我认为 C# 可能足够快,但我担心如何实现稀疏数组。
希望有帮助,听起来很有趣。
I've implemented a couple of systems that mimicked what OLAP cubes do, and here are a couple of things we did to get them to work.
The core data was held in an n-dimensional array, all in memory, and all the keys were implemented via hierarchies of pointers to the underlying array. In this way we could have multiple different sets of keys for the same data. The data in the array was the equivalent of the fact table, often it would only have a couple of pieces of data, in one instance this was price and number sold.
The underlying array was often sparse, so once it was created we used to remove all the blank cells to save memory - lots of hardcore pointer arithmetic but it worked.
As we had hierarchies of keys, we could write routines quite easily to drill down/up a hierarchy easily. For instance we would access year of data, by going through the month keys, which in turn mapped to days and/or weeks. At each level we would aggregate data as part of building the cube - made calculations much faster.
We didn't implement any kind of query language, but we did support drill down on all axis (up to 7 in our biggest cubes), and that was tied directly to the UI which the users liked.
We implemented core stuff in C++, but these days I reckon C# could be fast enough, but I'd worry about how to implement sparse arrays.
Hope that helps, sound interesting.
Microsoft SQL Server 2008 Analysis Services Unleashed一书详细阐述了 SSAS 的一些特殊性2008年,细节不错。 这并不完全是“SSAS 在幕后的工作原理”,但它很有启发性,尤其是在数据结构方面。 (关于确切的算法,它并不是那么详细/具体。)作为该领域的业余爱好者,我从这本书中收集了一些东西。 这就是 SSAS MOLAP 的全部内容:
无论如何,这些都是 SSAS 中发挥作用的一些因素。 我不能说没有其他重要的事情。
The book Microsoft SQL Server 2008 Analysis Services Unleashed spells out some of the particularities of SSAS 2008 in decent detail. It's not quite a "here's exactly how SSAS works under the hood", but it's pretty suggestive, especially on the data structure side. (It's not quite as detailed/specific about the exact algorithms.) A few of the things I, as an amateur in this area, gathered from this book. This is all about SSAS MOLAP:
These are some of the factors in play in SSAS anyway. I can't claim that there aren't other vital things as well.