Will the use of LTRIMs and RTRIMs in Stored Procedures improve performance, instead of using them in Triggers?

SQL Server
Hi All, I have a job running in SQL Server 2000. I have defined triggers on some tables. I have used LTRIMs and RTRIMs in my triggers. Now, there is a performance issue in my job. Its taking a lot amount of time for successful completion. I have been suggested to trim the data while inserting or updating in the base tables rather than doing the same in my triggers. The load procedures in my base tables is very simple. It simply pulls incremental data from a source database (also in SQL Server 2000). My concern is, will transferring the LTRIM RTRIM functions from the triggers to the Load Procedures of the base tables improve the performance of my job? Pls. suggest. Thanks in advance.

Answer Wiki

Thanks. We'll let you know when a new response is added.

No. Something else is going on. Please eMail a copy of the trigger code to sol@linker.com, and I’ll take a look at it for you.

Discuss This Question: 2  Replies

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • Solgonl
    It can also depend on which side of the equation the LTRIM or RTRIM is on. Some of the basic rules for search arguments (WHERE clauses) that can improve performance are to: --eliminate functions, arithmetic operations and other expressions on the column side of the WHERE clause, for example use this: where custName = RTRIM(@custName) don't do it like this: where RTRIM(custName) = @custName --eliminate incompatible data types, --use all of the search arguments you can possibly give to allow the optimizer more to work with, --try to use very selective search arguments
    0 pointsBadges:
  • Bwartman
    Removing triggers will generally increase performance. If your trigger is doing work other then adding the RTRIM/LTRIM will have minimal additional impact. If, however, the only thing that you're doing in the trigger is an LTRIM/RTRIM then I'd look at moving this operation into one of your data cleansing steps and dropping the trigger. For example, if your import process requires that most columns be trimmed then you can incorporate the LTRIM/RTRIM functions into your INSERT statement. If, OTOH if you import the incoming data into a staging table prior to insertion and relatively and there are relatively few rows that need trimming then you can use an UPDATE command to update the rows prior to insertion.
    0 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: