Sql server SSAS表格/DAX性能差

Sql server SSAS表格/DAX性能差,sql-server,ssas,dax,query-performance,ssas-tabular,Sql Server,Ssas,Dax,Query Performance,Ssas Tabular,我是SSAS表格和DAX的新手。 我已经建立了一个数据模型并成功地进行了处理。现在,我正在使用SSA表来代替SSR报表,而不是在数据仓库中命中表和索引视图。 我正在编写的这个特定DAX查询所针对的事实表的大小约为2.2亿条记录。 以下是查询: DEFINE VAR Ind_Fact_Summ_Matter_By_Day_By_Posted = //SAMPLE(1000, ADDCOLUMNS ( SUMMARIZE (

我是SSAS表格和DAX的新手。 我已经建立了一个数据模型并成功地进行了处理。现在,我正在使用SSA表来代替SSR报表,而不是在数据仓库中命中表和索引视图。 我正在编写的这个特定DAX查询所针对的事实表的大小约为2.2亿条记录。 以下是查询:

DEFINE
VAR Ind_Fact_Summ_Matter_By_Day_By_Posted =     
//SAMPLE(1000,
    ADDCOLUMNS
    (
        SUMMARIZE
        (
            'Revenue Summary',
            'Revenue Summary'[AK_Tran_Date],
            'Revenue Summary'[AK_Post_Date],
            'Revenue Summary'[AK_Period],
            'Revenue Summary'[AK_Current_Matter],
            'Revenue Summary'[AK_Matter],
            'Revenue Summary'[AK_Exchange_DateRange]
        ),
        "Debt_Total_Outstanding", CALCULATE([Total Debt Total Outstanding]), --CALCULATE(SUM('Revenue Summary'[Debt_Total_Outstanding]))
        "Fees_WIP_Amount", CALCULATE(SUM('Revenue Summary'[Fees_WIP_Amount])),
        "Disbs_Soft_WIP", CALCULATE(SUM('Revenue Summary'[Disbs_Soft_WIP])),
        "Disbs_Hard_WIP", CALCULATE(SUM('Revenue Summary'[Disbs_Hard_WIP])),
        "Disbs_Total_WIP", CALCULATE(SUM('Revenue Summary'[Disbs_Total_WIP])),
        "Fees_Base_Amount", CALCULATE(SUM('Revenue Summary'[Fees_Base_Amount])),
        "Debt_Total_Billed", CALCULATE(SUM('Revenue Summary'[Debt_Total_Billed])),
        "Net_Revenue", CALCULATE(SUM('Revenue Summary'[Net_Revenue])),
        "Fees_Net_Revenue", CALCULATE(SUM('Revenue Summary'[Fees_Net_Revenue])),
        "Other_Revenue", CALCULATE(SUM('Revenue Summary'[Other_Revenue])),
        "Total_Cost_Amt", CALCULATE(SUM('Revenue Summary'[Total_Cost_Amt])),
        "Fees_WIP_reserve", CALCULATE(SUM('Revenue Summary'[Fees_WIP_Reserve])),
        "Other_Disbs_WIP_Reserve", CALCULATE(SUM('Revenue Summary'[Other_Disbs_WIP_Reserve])),
        "Debt_Total_Reserve", CALCULATE(SUM('Revenue Summary'[Debt_Total_Reserve])),
        "Billable_Hours", CALCULATE(SUM('Revenue Summary'[Billable_Hours])),
        "Partner_Billable_Hours", CALCULATE(SUM('Revenue Summary'[Partner_Billable_Hours])),
        "Legal_Staff_Billable_Hours", CALCULATE(SUM('Revenue Summary'[Legal_Staff_Billable_Hours])),
        "Standard_Revenue_No_Secondment", CALCULATE(SUM('Revenue Summary'[Standard_Revenue_No_Secondment])),
        "Standard_Revenue_Secondment", CALCULATE(SUM('Revenue Summary'[Standard_Revenue_Secondment])),
        "Fees_Standard_Revenue", CALCULATE(SUM('Revenue Summary'[Fees_Standard_Revenue])),
        "Fees_Billed_WIP_Writeoff", CALCULATE(SUM('Revenue Summary'[Fees_Billed_WIP_Writeoff])),
        "Debt_Writeoff_Secondment", CALCULATE(SUM('Revenue Summary'[Debt_Writeoff_Secondment])),
        "Debt_Writeoff_No_Secondment", CALCULATE(SUM('Revenue Summary'[Debt_Writeoff_No_Secondment])),
        "WIP_Reserve", CALCULATE(SUM('Revenue Summary'[Fees_WIP_Reserve]) + SUM('Revenue Summary'[Other_Disbs_WIP_Reserve])),
        "Total_Reserve", CALCULATE(SUM('Revenue Summary'[Fees_WIP_Reserve]) + SUM('Revenue Summary'[Other_Disbs_WIP_Reserve]) + SUM('Revenue Summary'[Debt_Total_Reserve]))
    )
//  ,RAND()
//)
EVALUATE 
    Ind_Fact_Summ_Matter_By_Day_By_Posted
正如您所看到的,这是非常简单的DAX查询-聚合一些度量。 “收入汇总”是我所说的一个大事实表,它有2.2亿条记录。 当我在DAX Studio中运行查询时,由于内存限制,它失败了。 当我做样本或TOPN 1000时,花了5分钟!这只返回了1个聚合度量(我对其余的进行了注释-只是为了测试目的)

我不确定是型号、DAX、硬件还是它们的组合导致了如此糟糕的性能。 表格模型所在的开发服务器是虚拟服务器,具有以下规格(基于CPU-Z):

  • 英特尔至强E5(8核,4插槽)
  • 90GB内存
  • 内存类型:江户(不确定这是什么?!)
  • DRAM频率:66.0 Mhz(慢至??)
  • 在静止状态下,使用了47%的RAM。当我运行查询(没有TOPN 1000)时,由于内存限制和CPU利用率非常高,它一直运行到失败
此外,正如我前面提到的,我正在重新编写SSRS报告,该报告是使用索引视图编写的。 请注意,查询只是报表使用的较大查询的一部分。 报告大约运行一分钟,因此我正在探索使用SSAS表格加速报告的方法。 当我使用索引视图在SQL中执行等价查询的前1000个时,只花了1秒钟,所以看起来SSAS TABLAR在这里让我失败了

我应该做些什么来显著提高性能? 我做错了什么

任何指导都将不胜感激。 谢谢


编辑:在表格/内存/导入模式下使用SSAS 2016(非DirectQuery)

您的错误是使用“汇总”对某些列进行汇总,但不是全部! 您可以使用SummaryColumns,只需一次性汇总所有列,而不是:

VAR Ind_Fact_Summ_Matter_By_Day_By_Posted =     
//SAMPLE(1000,
    ADDCOLUMNS
    (
        SUMMARIZE
        (
            'Revenue Summary',
            'Revenue Summary'[AK_Tran_Date],
            'Revenue Summary'[AK_Post_Date],
            'Revenue Summary'[AK_Period],
            'Revenue Summary'[AK_Current_Matter],
            'Revenue Summary'[AK_Matter],
            'Revenue Summary'[AK_Exchange_DateRange]
        ),
        "Debt_Total_Outstanding", CALCULATE([Total Debt Total Outstanding]), --CALCULATE(SUM('Revenue Summary'[Debt_Total_Outstanding]))
        "Fees_WIP_Amount", CALCULATE(SUM('Revenue Summary'[Fees_WIP_Amount])),
        "Disbs_Soft_WIP", CALCULATE(SUM('Revenue Summary'[Disbs_Soft_WIP])),
        "Disbs_Hard_WIP", CALCULATE(SUM('Revenue Summary'[Disbs_Hard_WIP])),
或者不管你还有什么,只要去:

VAR Ind_Fact_Summ_Matter_By_Day_By_Posted =     
SUMMARIZE
            (
                'Revenue Summary',
                'Revenue Summary'[AK_Tran_Date],
                'Revenue Summary'[AK_Post_Date],
                'Revenue Summary'[AK_Period],
                'Revenue Summary'[AK_Current_Matter],
                'Revenue Summary'[AK_Matter],
                'Revenue Summary'[AK_Exchange_DateRange], 
'Revenue Summary'[Debt_Total_Outstanding],
'Revenue Summary'[Fees_WIP_Amount],
'Revenue Summary'[Disbs_Soft_WIP],
'Revenue Summary'[Disbs_Hard_WIP]
            )

在“添加列”部分绝对没有理由添加计算度量(除非已经预定义)。在ADDCOLUMNS部分中,我们添加了我们想要按其分组的属性。

只是想知道,DirectQuery模式没有启用,对吗?@AlexanderVolok我刚在SSMS中检查,数据库处于导入模式而不是DirectQuery模式。我要做的第一件事是注释掉所有度量值,除了一个,运行查询并计时。然后注释掉除下一个度量值之外的所有度量值并计时。我假设一个或多个措施是昂贵的或可以优化。一旦你找到了罪犯,就发布该措施及其所指的任何其他措施的DAX。@Greggallowy谢谢你的提示。仅供参考,所有这些都不是度量值,而是直接来自数据源(SQL Server表)的字段,第一个除外,[未偿债务总额]。我认为缓慢可能是因为事实表很大,有很多度量字段,每个度量字段的基数都很高,因为有很多不同的值,这无助于压缩,因此无法提高表格模型的性能。不确定如何进行优化。如果我只导入该事实表而不导入任何其他表,那么模型数据库本身将使用约38GB的RAM。如果查询完成,将返回多少行?如果没有未偿债务总额,查询是否快速?