Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Clustered index update Expand / Collapse
Author
Message
Posted Monday, February 7, 2011 1:06 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Tuesday, August 12, 2014 7:44 AM
Points: 93, Visits: 299
Hi

On our website when someone views a members image we update a field called visits which is just a counter that shows how many times an image has been viewed.

The sql statement looks like this : -

update images set visits=visits+1 where (username=@username) AND (mykey=@mykey)

However I have noticed that looking at the execution plan a clustered index update is taking place which is taking up 86%.

Anyone know why this might be?

Thanks
Matt
Post #1059874
Posted Monday, February 7, 2011 1:21 PM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Friday, June 27, 2014 12:43 PM
Points: 15,444, Visits: 9,596
The "clustered index" is, for all intents and purposes, the table itself. I would expect that to the majority of the work on a simple update.

In other words, this is normal and expected.

You'll want to take a look at how clustered indexes work. If you'll be administering or performance tuning, you'll need to know about them.


- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread

"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Post #1059880
Posted Monday, February 7, 2011 1:33 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 4:39 PM
Points: 33,155, Visits: 15,291
Also be aware that the execution plan adds up to 100%, so something will take up resources. If you have the index on fields that the update can use, then the resource usage should be minimal.






Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1059887
Posted Tuesday, February 8, 2011 7:31 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 3:34 PM
Points: 15,623, Visits: 28,007
Also, also, be cognizant of the fact that just becuase you have a high cost in an execution plan, doesn't mean that the process itself is very high cost. Execution plan costs are just estimates and do not represent measures that you can use to determine performance.

----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of: SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #1060210
Posted Tuesday, February 8, 2011 8:47 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Tuesday, August 12, 2014 7:44 AM
Points: 93, Visits: 299
Thanks for all your replies
Post #1060316
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse