ETL包的执行时间 - 脚本

时间:2015-12-30 11:16:07

标签: sql-server ssis etl

我使用下面的脚本来计算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块的执行时间。

2 个答案:

答案 0 :(得分: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 :(得分: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