Introduction to OLAP
数据库活动类型被分为两类
OLTP – Online Transaction Processing
- – Short transactions
- – Simple queries
- – Touch small portions of data
- – Frequent updates
OLAP – Online Analytical Processing
- – Long transactions
- – Complex queries
- – Touch large portions of the data
- – Infrequent updates
以上两种都是比较极端的类型,可能有数据库的类型属于两个极端的中间。
更多术语
Data warehousing :Bring data from operational (OLTP) sources into a single “warehouse” for (OLAP) analysis
Decision support system (DSS):Infrastructure for data analysis E.g., data warehouse tuned for OLAP
OLAP “Star Schema”
一个fact table:Updated frequently, often append-only, very large
多个dimension table:Updated infrequently, not as large
注意:Fact table可能有很多更新,但是OLAP query session may work on a single snapshot so no updates are involved!
可以把dimension table想象成真实世界的物品,fact table想象成是日志。
OLAP query 可能要经历 Join -> Filter -> Group -> Aggregate
性能表现:
- 会非常的慢 需要特殊的index,query processing 技巧
- 大量使用materialized view
Data Cube
把不同的表组合成一个类似坐标系的东西,原点代表了所有的数据,边上代表了某个具体的表的数据,面上代表了两个表集合的数据,空间的任意一点代表了某个具体信息。
Drill-Down
我们需要更多的信息,更多的detail,下图中在sql语言加了一个category
Roll-Up
和drill-down相反,我们不需要那么多的detail,如下图中
SQL-constucts
Jennifer 在demo课中使用的语言是mysql,在2014年课程开出来的时候Postgres和SQLite还不支持rollup
具体的例子可以参考demo视频!