Performance Tuning in SQL Server 2000
Performance Tuning in SQL Server 2000
The goal of performance tuning is to minimize the response time for each query and to
maximize the throughput of the entire database server by reducing network traffic, disk
I/O, and CPU time. This goal is achieved through understanding application
requirements, the logical and physical structure of the data, and tradeoffs between
conflicting uses of the database, such as online transaction processing (OLTP) versus
decision support.
To most effectively optimize the performance of Microsoft® SQL Server™ 2000, you
must identify the areas that will yield the largest performance increases over the widest
variety of situations and focus analysis on those areas.
To achieve the high levels of performance required by the largest Web sites, a multi tier
system typically balances the processing load for each tier across multiple servers.
Microsoft® SQL Server™ 2000 shares the database processing load across a group of
servers by horizontally partitioning the SQL Server data. These servers are managed
independently, but cooperate to process the database requests from the applications; such
a cooperative group of servers is called a federation.
A federated database tier can achieve extremely high levels of performance only if the
application sends each SQL statement to the member server that has most of the data
required by the statement. This is called collocating the SQL statement with the data
required by the statement. Collocating SQL statements with the required data is not a
requirement unique to federated servers. It is also required in clustered systems
Database Design:
There are two components to designing a database: logical and physical. Logical database
design involves modeling your business requirements and data using database
components, such as tables and constraints, without regard for how or where the data will
be physically stored. Physical database design involves mapping the logical design onto
physical media, taking advantage of the hardware and software features available, which
allows the data to be physically accessed and maintained as quickly as possible, and
indexing.
It is important to correctly design the database to model your business requirements, and
to take advantage of hardware and software features early in the development cycle of a
database application, because it is difficult to make changes to these components later.
Query Tuning:
Most of the performance problem can be resolved by analyzing the by analyzing the
application, queries, and updates that the application is submitting to the database, and
how these queries and updates interact with the database schema.
When a query or update takes longer than expected, use the following checklist to
improve performance.
In SQL Query Analyzer, you can also turn on the graphical execution plan
option to view a graphical representation of how SQL Server retrieves data.
The information gathered by these tools allows you to determine how a query is
executed by the SQL Server query optimizer and which indexes are being used.
Using this information, you can determine if performance improvements can be
made by rewriting the query, changing the indexes on the tables, or perhaps
modifying the database design.
Monitor the query using SQL Profiler or the graphical execution plan in SQL
Query Analyzer to determine if the query has enough statistics.
5. Are the query statistics up-to-date? Are the statistics automatically updated?
SQL Server automatically creates and updates query statistics on indexed columns
(as long as automatic query statistic updating is not disabled). Additionally,
statistics can be updated on nonindexed columns either manually, using SQL
Query Analyzer or the UPDATE STATISTICS statement, or automatically, if the
auto update statistics database option is set to true. Up-to-date statistics are not
dependent upon date or time data. If no UPDATE operations have taken place,
then the query statistics are still up-to-date.
If statistics are not set to update automatically, then set them to do so.
6. Are suitable indexes available? Would adding one or more indexes improve query
performance?
7. Are there any data or index hot spots? Consider using disk striping.
8. Is the query optimizer provided with the best opportunity to optimize a complex
query?.
Application Design
Application design plays a pivotal role in determining the performance of a system using
Microsoft® SQL Server™ 2000. Consider the client the controlling entity rather than the
database server. The client determines the type of queries, when they are submitted, and
how the results are processed. This in turn has a major effect on the type and duration of
locks, amount of I/O, and processing (CPU) load on the server, and hence on whether
performance is generally good or bad.
For this reason, it is important to make the correct decisions during the application design
phase. However, even if a performance problem occurs using a turn-key application,
where changes to the client application seem impossible, this does not change the
fundamental factors that affect performance: The client plays a dominant role and many
performance problems cannot be resolved without making client changes.
A well-designed application allows SQL Server to support thousands of concurrent users.
Conversely, a poorly designed application prevents even the most powerful server
platform from handling more than a few users.