Thursday, March 11, 2004

ADO.NET performance tuning 

I was debugging a long-running page and thought the SQL was too complex. I checked the SP run time, and it seemed OK. I then started getting some error messages about timeouts and the connection pool being exhausted. The problem was that I was not closing the DataReader. I usually wouldn't even notice the problem (the reader is eventually closed anyway), but the statement was in a loop, so it was evident quite quickly.

I went through the code and made sure every ".Read()" was either in a using() statement or followed by a .Close. The page performance improved quite a bit (from timing out to less than 2 sec!), and the other pages are faster, too.

Comments: Post a Comment

This page is powered by Blogger. Isn't yours?