最大限度地减少大数据中SQL查询的时间消耗

时间:2017-02-21 09:33:48

标签: sql sql-server azure

这里我使用BI工具在Azure SQL中运行以下查询以从大卷中获取数据.BI工具在以下查询中显示以下错误The query exceeded the maximum allowable time of execution time of 10 seconds

SELECT M + ' ' +Convert(varchar,CY) TimeSpan,
       ISNULL(SUM([Australia]), 0) AS [Australia],
       ISNULL(SUM([India]), 0) AS [India],
       ISNULL(SUM([America]), 0) AS [America]
       FROM (
                select Distinct DeviceID,RegionName, Month(LastCommunicated) CM, Year(LastCommunicated) CY, 1 Cnt
                ,LEFT(DATENAME(MONTH,LastCommunicated),3) M
                from Region
                WHERE LastCommunicated BETWEEN DATEADD(year,-1,GETDATE()) and dateadd(day,datediff(day,0,GETDATE()),0)
             ) a 
               PIVOT (Sum(Cnt) FOR RegionName IN ([Australia],[India],[America])) AS Result
       GROUP BY CY,CM,M + ' ' +Convert(varchar,CY)
        ORDER BY CY,CM

是否有其他方法可以解决此问题,而不是增加BI中的执行时间?

0 个答案:

没有答案