19.0 Introduction


Performance has been a concern of ours throughout this book, and we have endeavored to provide you with production-ready code that will perform well in any setting. And when a recipe involves trade-offs between performance and ease of implementation, we strive to bring these to your attention. Nevertheless, when an application is not performing as well as you would like, you can improve matters by altering its handling of the following elements:


ViewState

You can often improve a page's performance by disabling the ViewState for the page or some of its controls, but you have to be aware of the consequences.


String concatenation

You've probably heard that it is better to use the StringBuilder object to build strings rather than the classic concatenation operators (& and +). But you may be wondering how much better it is and if it applies to your situation.


Data access

With the different options available for data access, ways to improve data access performance exist, especially when choosing between the two primary methods for reading data from a databasei.e., via a DataReader or a DataAdapter.


SQL Server managed provider

For the sake of database interoperability, the bulk of the recipes in this book show how to access data using the OleDB managed provider. Yet because of the performance that can be garnered, much can be said for using the SQL Server managed provider instead when you know the application will always access SQL Server 7.0 or later.

All of these topics are addressed in the recipes in this chapter.

Like all other programming tools, ASP.NET and the common language runtime (CLR) provide many different ways to accomplish a given task. And because each application is unique and there is no one "right" way to approach it, every application's performance is worthy of review, mitigated by its frequency of use and its significance. With this in mind, you may want to consider these performance-oriented recipes as much for their approaches to performance tuning as for their line-for-line coding techniques.

As you evaluate the comparisons we've made in this chapter between different data access methods, you should know that the measurements were made on a 1.7 GHz Pentium 4 PC with 1GB of memory. Your mileage may vary.

The side-by-side test results presented in this chapter's examples should be used to compare the relative differences between data access methods. The time to retrieve data is a function of the hardware, the database, the fragmentation of the data, and other variables.




ASP. NET Cookbook
ASP.Net 2.0 Cookbook (Cookbooks (OReilly))
ISBN: 0596100647
EAN: 2147483647
Year: 2003
Pages: 202

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net