Josef Richberg
Josef Richberg

Reputation: 613

SSIS script transformation task taking way to long

I have the following script transformation component.

public class ScriptMain : UserComponent
{
    Regex findCOMMAexp, findAmpersandExp, findANDExp;

    public override void PreExecute()
    {
        base.PreExecute();

        //extract and compress publishers.
        findANDExp = new Regex(@"(\w+\s*)+(?=\band\b)",RegexOptions.Compiled);
        findCOMMAexp = new Regex(@"(\w+\s*)+[,]\s*(\w+\s*)",RegexOptions.Compiled);
        findAmpersandExp = new Regex(@"(\w+\s*)+[&]\s*(\w+\s*)",RegexOptions.Compiled);
    }

    public override void PostExecute()
    {
        base.PostExecute();
    }

    public override void Input0_ProcessInputRow(Input0Buffer Row)
    {        
        Row.CompressedPublisher = compressPublisher(Row.F018Publisher);
    }

    public String compressPublisher(String str)
    {

        Match match;

        if (str.Contains("/"))
        {
            return str.Substring(0, str.IndexOf(('/')));
        }
        else if ((match = findANDExp.Match(str)).Success)
        {
            return match.ToString();
        }
        else if ((match = findCOMMAexp.Match(str)).Success)
        {
            return Regex.Replace(str, ",", "");
        }
        else
        {
            return str;
        }
    }
}

The 3 Regex objects are defined in the main class, initialized in the PreExecute(), and used in a method called by the ProcessInputRow. I have a database source that pulls in a single varchar(45) string, defined as F018Publisher. I stopped this task after 10 mins, while trying to parse 9k entries. What is going wrong?

Thanks.

Upvotes: 0

Views: 693

Answers (1)

billinkc
billinkc

Reputation: 61269

I wrapped this into a C# commandline app and passed ABCDEFGHIJKLMOPQRSTUVWXYZ01234567890123456789 as a parameter to compressPublisher and it never returned from this check else if ((match = findANDExp.Match(str)).Success)

Same comment posted to twitter as well

Upvotes: 1

Related Questions