Microsoft Knowledge Base Email Alertz

How to measure the rate at which rows pass through a particular data flow task in a SQL Server 2005 Integration Services (SSIS) package

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 911838 - Last Review: December 16, 2005 - Revision: 1.1

How to measure the rate at which rows pass through a particular data flow task in a SQL Server 2005 Integration Services (SSIS) package

INTRODUCTION

You may want to measure the rate at which rows pass through a particular data flow task in a Microsoft SQL Server 2005 Integration Services (SSIS) package. However, you cannot use the Performance Monitor tool (Perfmon.exe) to monitor this performance by adding counters in the SQLServer:SSIS Pipeline object. This article describes a simple method that you can use to measure the rate. You can use a Script component data flow transformation in the data flow. The Script component data flow transformation contains a script that returns the minimum rate, the maximum rate, and the median rate at which rows pass through the data flow task.

MORE INFORMATION

To measure the rate at which rows pass through the data flow task, use the following script in a Script component data flow transformation in the Integration Services package.
Imports System

Imports System.Data

Imports System.Data.OleDb

Imports System.Collections

 

Public Class ScriptMain

    Inherits UserComponent

 

    Private startTicks, totalTicks As Long

    Private rowCount, totalRows As Integer

    Private rps As New ArrayList() 'rps = rows per second

 

    Public Overrides Sub Input0_ProcessInput(ByVal Buffer As Input0Buffer)

        'Save the rate statistic for this buffer

        If startTicks <> 0 Then

            totalRows += rowCount

            Dim ticks As Long = CLng(DateTime.Now.Ticks - startTicks)

            If ticks > 0 Then

                totalTicks += ticks

                Dim rate As Integer = CInt(rowCount * (TimeSpan.TicksPerSecond / ticks))

                rps.Add(rate)

            End If

        End If

        'Reinitialize the counters

        rowCount = 0

        startTicks = DateTime.Now.Ticks

        'Call the base method

        MyBase.Input0_ProcessInput(Buffer)

    End Sub

 

    Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)

        rowCount += 1 'No exposed Buffer.RowCount property. Therefore, you have to count manually

    End Sub

 

    Public Overrides Sub PostExecute()

        MyBase.PostExecute()

 

        'Only write the extended stats if RowCount > 0

        If rps.Count > 0 Then

            'Calculations depend on sorted array

            rps.Sort()

            'Remove boundary-case statistics

            If rps.Count >= 3 Then rps.RemoveAt(0)

            'Calculate min and max

            Dim min As Integer = CInt(rps.Item(0))

            Dim max As Integer = CInt(rps.Item(rps.Count - 1))

            'Display results

            MsgBox("Min=" & CStr(min) & vbCrLf & "Max=" & CStr(max) & vbCrLf & "Mean=" & CStr(min + max \ 2))

        End If

    End Sub

End Class
Note In this code, the MsgBox function is used to display the statistics results. However, when you use this code in a real implementation, it may be useful to output the statistics to a table that can be used for trend analysis.

REFERENCES

For more information, see the following topics in SQL Server 2005 Books Online:
  • Script component
  • Coding and testing the Script component

APPLIES TO
  • Microsoft SQL Server 2005 Standard Edition
  • Microsoft SQL Server 2005 Developer Edition
  • Microsoft SQL Server 2005 Enterprise Edition
Keywords: 
kbexpertiseadvanced kbsql2005ssis kbinfo KB911838
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate