Question : SQL Server 2005 Enterprise update query takes too long.

When I run this query on my server on a 200MB database with 50k records it takes an hour to complete and the website which uses this database does not respond anymore, why?
The CPU Usage is 52% on core2 CPU, 4GB RAM

UPDATE MyDatabase
   SET [ExpirationDate] = '10/10/2010'      
 WHERE [ExpirationDate] < '10/10/2010'

Note: The ExpirationDate field is indexed.

Answer : SQL Server 2005 Enterprise update query takes too long.

And we dig deeper, what does UpdateCategoryAdCounts do?

I also researched a bit and realised that "clustered index update" means "using the clustered index to perform an update".  Because of your trigger code accessing it by ID, that makes sense.  I recall seeing index rebuild operations showing in the Query Plan if a clustered index (itself) is updated, which is not shown here.

I don't know how you will take to disabling the trigger, but try this

DISABLE TRIGGER [dbo].[classifieds_Ads] ON  [dbo].[AdUpdated]

When the update has finished,

ENABLE TRIGGER [dbo].[classifieds_Ads] ON [dbo].[AdUpdated]

The trigger code is not efficient, but that could be another question.
Random Solutions  
 
programming4us programming4us