Do not use on any
shared computer
August 30, 2008 12:22am pdt
 
[x]
Attachment Details

Triggers and Alternatives

Tags: TSQL - SQL Server 2K, NA, NA
Hi,
I have a trigger on a table which calclates an average based on records inserted into a table.  The average is calculated based on one key field in the record(s)

So, for example, if I insert a record with key = 'A',  every time I insert a record, I calculate the average for all records with key =- 'A'.   There are times when there could be several hundred records with key = 'A'.  As the number of records with like 'keys' increases,  trigger performance suffers terribly... and all users are subjected to degraded response time.   I have observed the performance 'hit' in Profiler... trigger duration can exceed 400 ms... very bad.

I have tested a change to the S/P that does the inserts.  By calculating the average in the s/p using the 'Nolock' locking hint, I pretty much conquer the issue.  Problem is, I don't trust 'Nolock'.  It shouldn't be a problem because these records are almost NEVER updated or deleted....  so I'm always working with the most recently inserted record (which is the one just done within the stored procedure.

Any ideas on alternative approaches?  I'd really like to hear what you guys have done in similar situations.

Thanks,

tom (wherewasi)
Start your free trial to view this solution
Question Stats
Zone: Microsoft
Question Asked By: wherewasi
Question Asked On: 06.24.2008
Participating Experts: 2
Points: 500
Views: 0
Translate:
Loading Advertisement...
 
[+][-]Expert Comment by GreenGhost

Rank: Master

Expert Comment by GreenGhost:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by ScottPletcher

Rank: Genius

Expert Comment by ScottPletcher:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080723-EE-VQP-34 / EE_QW_2_20070628