:-$

Ryan's work blog

My Links

News

The WeatherPixie
Subscribe with Bloglines
About this blog

Tools I use:

Post Categories

Article Categories

Archives

Image Galleries

Blog Stats

Personal

Projects

Random Blogs

Random other

Reference

Web comics

Work

NETWORKIO locks on SQL Server 2000

Recently I was doing some perfomance tuning for a client, who kept getting timeouts. The timeouts were being caused by some locking queries, with a lock type of "NETWORKIO". This is odd, as everything was running on the same server, so it shouldn't really have much network IO when connecting to 127.0.0.1.

My solution

After much frustraction and googling, I saw someone recommend updating statistics using sp_updatestats to speed up queries, which might resolve NETWORKIO locks faster. That made all the difference. Now the site is zippy as hell. But why did that work?

After some cursory research, I found that sp_updatestats is a convienence function for running UPDATE STATISTICS on every table in the current database. The statistics they talk about are about the keys in each index on the table. The stats are then analyzed by the query optimizer to get the best usage of indexes. If you do a "display estimated execution plan" on a query, the stats are whats used to make those estimates. Then it made sense.

In an earlier attempt to speed everything up, I had taken a trace of the activity and ran the index tuning wizard on about an hours worth of actual usage. Applying the recommended indexes sped up the site nicely, but the real benefit wasn't realized because the statistics on the new indices hadn't been calculated, so the query optimizer couldn't do its job very well. After getting my stats lined up, the optimizer kicked in and everything was very responsive.

Conclusion

If you change your indexes about, run EXEC sp_updatestats. There is an option on a database maintanence plan to do this, and I believe I'm going to start enabling it.

posted on Friday, May 12, 2006 1:52 PM