Turn from:
http://www.bitstech.net/2016/01/04/kylin-olap/
http://www.csdn.net/article/2015-11-27/2826343
http://tech.youzan.com/kylin-mondrian-saiku/
Apache Kylin improvements to traditional MOLAP
Calculating the storage cost of cube and calculating cost are relatively large, and the problem of the dimension explosion of traditional OLAP is kylin also encountered. Kylin provides users with some optimization measures that can, to a certain extent, reduce the problem of dimension explosions:
- Cube Optimization:
- Hierachy Dimension
- Derived Dimension
- Aggregation Group
Hierachy Dimension, a series of hierarchical relations Dimension composed of a hierachy, such as the year, the month, the day composed of a hierachy, in the cube, if not set hierarchy, will be years, months, days, months, year, month, day 6 cuboid, but after setting up the hierarchy, cuboid added a constraint, hoping that the low level dimension must accompany the dimension of the height. The Hierachy Dimension is set to halve the dimension combinations that need to be computed.
Derived Dimension, if you have more than one dimension on a dimension table, you can set it to Derived Dimension, which is replaced by the primary key of the dimension table in Kylin, so as to reduce the number of dimension combinations. Of course, to a certain extent derived Dimension will reduce the efficiency of the query, when the query, Kylin using the primary key of the dimension table to aggregate, and then through the primary key and the true Dimension column mapping relationship to do a conversion, in the kylin inside the result set once aggregated and returned to the user
Aggregation Group, which is a means of grouping dimensions in order to reduce the number of dimension combinations. The number of cuboid between the dimensions of different groupings will be greatly reduced, the dimension combination from 2 (k+m+n) power can be reduced to 2 of the K Power plus 2 m power plus 2 n power. The group's optimization measures are closely dependent on query SQL, which can be said to be a custom optimization for queries. If the dimension of the query is a kua group, then Kylin needs to aggregate the desired query results from the n-cuboid at a significant cost, which requires the cube builder to carefully weigh in modeling.
- Data compression:
Apache Kylin uses a special compression algorithm for dimension dictionaries and dimension table snapshots, which leverages Hadoop's lzo or snappy for aggregated computational data in hbase, ensuring that data stored in hbase and in-memory is as small as possible. The compression of dimension dictionaries and dimension table snapshots takes into account that there are very many duplicate dimension member values in Datacube, the most straightforward way is to map dimension values to IDs using the data dictionary and encode the dimension values using the Trie tree in Kylin
- Distinct Count aggregation query optimizations:
Apache Kylin uses the Hypeloglog method to calculate the DistinctCount. The advantage is that the speed is fast, the disadvantage is that the result is an approximate value, there will be some error. It is generally acceptable to apply the statistical error of DistinctCount in non-billable and other common scenarios.
The specific algorithm can be seen paper, this article will not repeat:
Http://algo.inria.fr/flajolet/Publications/FlFuGaMe07.pdf
Practice summary of using Apache Kylin
1, the big fact table uses the day partition increment constructs, in order not to affect the query performance, may do the merger periodically (merge), the cycle can determine according to the actual situation, we once a week merges.
2, for a larger dimension table, or query the select part of a complex logical judgment, there are functions or statements that are not supported by Apache Kylin, you can create a hive view of the fact table and the dimension table, and then create a cube model based on the view.
3, each query must be accompanied by the conditions suggested in the dictionary setup step to set it to mandatory. This will eventually build out the cube's size will be reduced by half.
4, Cube dimension if more than 10, it is recommended that the commonly used aggregate fields to do grouping, we for the largest 16 dimensions divided into three groups, each group about 5 dimensions.
5, cube definition in the Rowkey order: mandatory dimension, where the frequency of the filter conditions in the more frequent dimensions, high cardinality dimension, low cardinality dimension.
6, for hierarchies,derived dimension configuration optimization can refer to Community documentation:
Http://kylin.incubator.apache.org/docs/howto/howto_optimize_cubes.html
7, the deployment level, can be done by Nginx in the front-end load balancer, the backend to start multiple query server to receive processing requests.
"Turn" Kylin optimization