在使用蒙德里安的查询过程中发生了什么?

时间:2016-02-26 07:45:08

标签: olap mondrian

我知道mondrian将MDX查询转换为关系查询并返回结果。但是有没有关于这个过程的细节?

我使用样本立方体HR。这是MDX:

WITH
SET [~ROWS] AS
    TopCount({[Time].[Time].[Month].Members}, 3, [Measures].[Org Salary])
SELECT
NON EMPTY {[Measures].[Org Salary]} ON COLUMNS,
NON EMPTY [~ROWS] ON ROWS
FROM [HR]

这是MDX生成的SQL。我在日志中找到它:

select
    "time_by_day"."the_year" as "c0",
    "time_by_day"."quarter" as "c1",
    "time_by_day"."the_month" as "c2",
    "time_by_day"."month_of_year" as "c3",
    sum("salary"."salary_paid") as "c4"
from
    "salary" as "salary",
    "time_by_day" as "time_by_day"
where
    "time_by_day"."the_year" = 1997
and
    "salary"."pay_date" = "time_by_day"."the_date"
group by
    "time_by_day"."the_year",
    "time_by_day"."quarter",
    "time_by_day"."the_month",
    "time_by_day"."month_of_year"
order by
    CASE WHEN sum("salary"."salary_paid") IS NULL THEN 1 ELSE 0 END, sum("salary"."salary_paid") DESC,
    CASE WHEN "time_by_day"."the_year" IS NULL THEN 1 ELSE 0 END, "time_by_day"."the_year" ASC,
    CASE WHEN "time_by_day"."quarter" IS NULL THEN 1 ELSE 0 END, "time_by_day"."quarter" ASC,
    CASE WHEN "time_by_day"."the_month" IS NULL THEN 1 ELSE 0 END, "time_by_day"."the_month" ASC,
    CASE WHEN "time_by_day"."month_of_year" IS NULL THEN 1 ELSE 0 END, "time_by_day"."month_of_year" ASC

我将前三名改为前十名,我得到了相同的SQL 。 SQL没有像"限制"。

所以我想知道在查询过程中发生了什么?我搜索过并没有获得任何有用的信息。有人可以帮忙吗?

谢谢。

龙兴

1 个答案:

答案 0 :(得分:1)

如果您查看您的蒙德里安日志,您会看到有关此内容的信息:

  • SqlMemberSource.getMemberChildren
  • SqlTupleReader.readTuples
  • SqlStatisticsProvider.getColumnCardinality
  • Segment.load

Mondrian正在读取tubles并从SQL加载段,让数据库执行一些计算,并在内部完成其余的工作。根据您的MDX,架构和设置,它将为数据库和内部计算提供不同的任务,尝试以性能和内存最佳方式解决它。考虑到它应该具有最佳的缓存以供将来查询。