我已通过BIDS查询设计器构建了此查询。但我希望通过删除最外面的FROM子句中的SELECTS并且只在from子句中使用cube并在where或filter子句中使用rest过滤来优化此查询:
SELECT { [Measures].[User ID Distinct Count], [Measures].[Post Count], [Measures].[Like Count], [Measures].[Comment Count], [Measures].[Impressions Master Count] } ON COLUMNS,
NON EMPTY { ([Section Master].[Section Name].[Section Name].ALLMEMBERS * [Post Master].[Post Name].[Post Name].ALLMEMBERS * [Post Master].[SP Insert Date].[SP Insert Date].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS
FROM ( SELECT ( STRTOSET(@SectionMasterSectionName) ) ON COLUMNS
FROM ( SELECT ( STRTOMEMBER(@FromDimDateDate) : STRTOMEMBER(@ToDimDateDate) ) ON COLUMNS
FROM [AnalyticsCube]))
CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS
我是MDX的新手,对MDX查询优化知之甚少。因此,我也不知道这是查询的优化版本,或者仍然存在优化的范围。我的立方体结构显示在图像中。
how to display textBox control in MessageBox?
我通过在行和列部分中进行一些更改来更新我的旧查询,但仍然坚持使用From Clause部分
SELECT { [Measures].[User ID Distinct Count],
[Measures].[Post Count],
[Measures].[Like Count],
[Measures].[Comment Count],
[Measures].[Impressions Master Count] } ON COLUMNS,
NON EMPTY { ([Section Master].[Section Name].CHILDREN) *
([Post Master].[Post Name].CHILDREN, [Post Master].[SP Insert Date].CHILDREN ) } ON ROWS
FROM ( SELECT ( STRTOSET(@SectionMasterSectionName) ) ON COLUMNS
FROM ( SELECT ( STRTOMEMBER(@FromDimDateDate) : STRTOMEMBER(@ToDimDateDate) ) ON COLUMNS
FROM [AnalyticsCube]))
答案 0 :(得分:0)
这将是最初的简化:
SELECT
{
[Measures].[User ID Distinct Count]
,[Measures].[Post Count]
,[Measures].[Like Count]
,[Measures].[Comment Count]
,[Measures].[Impressions Master Count]
} ON COLUMNS
,NON EMPTY
{
[Section Master].[Section Name].Children
*
(
[Post Master].[Post Name].Children
,[Post Master].[SP Insert Date].Children
)
} ON ROWS
FROM
(
SELECT
StrToSet(@SectionMasterSectionName) ON 0,
StrToMember(@FromDimDateDate) : StrToMember(@ToDimDateDate) ON 1
FROM [AnalyticsCube]
);
然后我觉得你没有把StrToSet(@SectionMasterSectionName)
移到主SELECT子句中似乎很奇怪:
SELECT
{
[Measures].[User ID Distinct Count]
,[Measures].[Post Count]
,[Measures].[Like Count]
,[Measures].[Comment Count]
,[Measures].[Impressions Master Count]
} ON COLUMNS
,NON EMPTY
{
StrToSet(@SectionMasterSectionName)
*
(
[Post Master].[Post Name].Children
,[Post Master].[SP Insert Date].Children
)
} ON ROWS
FROM
(
SELECT
StrToMember(@FromDimDateDate) : StrToMember(@ToDimDateDate) ON 0
FROM [AnalyticsCube]
);
从逻辑上讲,它稍有不同,但您可以考虑使用WHERE
子句而不是SUB-SELECT
:
SELECT
{
[Measures].[User ID Distinct Count]
,[Measures].[Post Count]
,[Measures].[Like Count]
,[Measures].[Comment Count]
,[Measures].[Impressions Master Count]
} ON COLUMNS
,NON EMPTY
{
StrToSet(@SectionMasterSectionName)
*
(
[Post Master].[Post Name].Children
,[Post Master].[SP Insert Date].Children
)
} ON ROWS
FROM [AnalyticsCube]
WHERE
StrToMember(@FromDimDateDate) : StrToMember(@ToDimDateDate);