2015-12-30 146 views
2

我使用下面的脚本来calcute ETL包的执行时间:执行时间 - 脚本

DECLARE @DATE DATE = GETDATE() - 7 

SELECT 
     [folder_name] 
     ,[project_name] 
     ,[package_name] 
     ,CAST([start_time] AS datetime) AS [start_time] 
     ,DATEDIFF(minute, [start_time], [end_time]) AS 'execution_time[min]' 
FROM [SSISDB].[internal].[execution_info] 
WHERE start_time >= @DATE 
ORDER BY [start_time] 

这有可能增加粒度级别?我想要有每个ETL块的执行时间。

回答

3

您可以。以下查询应该返回每个可执行文件的持续时间。

DECLARE @DATE DATE = GETDATE() - 7 

SELECT [executions].[folder_name] 
     , [executions].[project_name] 
     , [executions].[package_name] 
     , [executable_statistics].[execution_path] 
     , DATEDIFF(minute, [executable_statistics].[start_time], [executable_statistics].[end_time]) AS 'execution_time[min]' 
FROM [SSISDB].[catalog].[executions] 
INNER JOIN [SSISDB].[catalog].[executable_statistics] 
    ON [executions].[execution_id] = [executable_statistics].[execution_id] 
WHERE [executions].[start_time] >= @DATE 
ORDER BY [executable_statistics].[start_time] 

您可以找到有关在SSISDB目录here不同的视图的详细信息。

1

另一种解决方案:

Use SSISDB 
DECLARE @DATE DATE = GETDATE() -7 

SELECT  
      CAST(MSG.message_time AS datetime) AS message_time 
      ,CASE message_source_type 
       WHEN 10 THEN 'Entry APIs, such as T-SQL and CLR Stored procedures' 
       WHEN 20 THEN 'External process used to run package (ISServerExec.exe)' 
       WHEN 30 THEN 'Package-level objects' 
       WHEN 40 THEN 'Control Flow tasks' 
       WHEN 50 THEN 'Control Flow containers' 
       WHEN 60 THEN 'Data Flow task' 
      END AS message_source_type 
      ,CAST(start_time AS datetime) AS start_time 
      ,OPR.object_name 
      ,LEFT(message, CHARINDEX(':', message) -1) AS Block 
      ,CONVERT(TIME(0), LEFT(RIGHT(message, 13),12)) AS execution_time 
FROM  catalog.operation_messages AS MSG 
INNER JOIN catalog.operations AS OPR 
    ON  OPR.operation_id = MSG.operation_id 
WHERE 
    start_time > @DATE 
    and message like '%:Finish%' 
    and message not like 'INSERT Record SQL Task:Finished%' 
    and message_source_type <> 30 
    and message_source_type <> 50 
--ORDER BY message_time DESC 
ORDER BY execution_time DESC