Tuning and
Optimizing Queries using Microsoft SQL Server 2005
Elements of this syllabus are subject to change.
This three-day instructor-led workshop provides database developers working in enterprise environments using Microsoft® SQL Server™ 2005 the knowledge and skills to evaluate and improve queries and query response times. The workshop focuses on systematic identification and optimization of database factors that impact query performance.
This course is intended for current professional
database developers who have three or more years of on-the-job experience
developing SQL Server database solutions in an enterprise environment.
After completing this course, students will be able to:
§
Normalize
databases.
Design
a normalized database.
Optimize
a database design by denormalizing.
§
Optimize
data storage.
§
Manage
concurrency
Manage
concurrency by selecting the appropriate transaction isolation level.
Select
a locking granularity level.
§
Optimize
and tune queries for performance.
§
Optimize
an indexing strategy.
§
Decide
when cursors are appropriate.
§
Identify
and resolve performance-limiting problems.
Before attending this course, students must:
·
Have
working knowledge of data storage.
Specifically, knowledge about row layout, fixed length field placement
and varying length field placement.
·
Be
familiar with index structures and index utilization. Specifically, they must understand the
interaction between non-clustered indexes, clustered indexes and heaps. They must know why a covering index can
improve performance.
·
Have
had hands-on database developer experience. Specifically, three
years of experience as a full-time database developer in an enterprise
environment.
·
Be
familiar with the locking model.
Specifically, students should have an understanding of lock modes, lock
objects and isolation levels and be familiar with process blocking.
·
Understand
Transact-SQL syntax and programming logic. Specifically,
students should be completely fluent in advanced queries, aggregate queries,
subqueries, user-defined functions, cursors, control of flow statements, CASE
expressions, and all types of joins.
·
Be able
to design a database to third normal form (3NF) and know the trade
offs when backing out of the fully normalized design (denormalization) and
designing for performance and business requirements in addition to being
familiar with design models, such as Star and Snowflake schemas.
·
Have
strong monitoring and troubleshooting skills, including using
monitoring tools.
·
Have
basic knowledge of the operating system and platform. That
is, how the operating system integrates with the database, what the platform or
operating system can do, and how interaction between the operating system and
the database works.
·
Have
basic knowledge of application architecture. That is, how
applications can be designed in three layers, what applications can do, how
interaction between the application and the database works, and how the
interaction between the database and the platform or operating system works.
·
Know
how to use a data modeling tool.
·
Be
familiar with SQL Server 2005 features, tools, and technologies.
·
Have a Microsoft®
Certified Technology Specialist: Microsoft SQL Server 2005
credential – or equivalent experience.
In addition, it is recommended, but not required, that students have completed:
·
Course
2778, Writing Queries Using Microsoft SQL Server 2005 Transact-SQL.
·
Course
2779, Implementing a Microsoft SQL Server 2005 Database.
·
Course
2780, Maintaining a Microsoft SQL Server 2005 Database.
Unit 1: Measuring Database Performance
This unit provides students with an opportunity to measure database performance and identify database performance bottlenecks. Students will use a sample script to identify performance and concurrency problems, capture baseline performance, and prioritize identified problems for optimization.
|
Topics |
|
§
Best Practices for Measuring
Performance § Key Measures for Query Performance § Using Performance Monitor §
Using SQL Server Profiler § Guidelines for Identifying Locking and Blocking |
|
Lab: Measuring Database Performance |
|
§
Reviewing Tables and Scripts §
Capturing Baseline
Performance §
Prioritizing Identified
Problems |
After completing this unit, students will be able to:
§
Describe best practices for
measuring performance.
§
Describe the key measures for
query performance.
§
List the useful Performance
Monitor counters for performance tuning.
§
List the useful Profiler trace
events for problem identification.
§
Select the best methods for
identifying which procedures are causing locking and blocking.
§
Review database tables and
scripts.
§
Identify performance and
concurrency problems by using a script.
§
Capture baseline performance.
§
Prioritize identified problems.
Unit 2: Optimizing Physical Database Design
In this unit, students
work with strategies for optimizing physical database design. Students will
optimize a database schema using normalization, generalization, and
denormalization.
|
Topics |
|
§
Performance Optimization
Model § Importance of Schema Design in Optimization §
Normalization §
Responsible Denormalization § Generalization §
Demonstration: How to Modify
the Database Schema |
|
Lab: Optimizing Physical Database Design |
|
§
Optimizing Memberships §
Optimizing Events § Normalizing Event Sponsorships § Denormalizing Membership Visits and Cleaning Up the Schema §
Comparing the Solution and Determining
Performance |
After completing this unit, students will be able to:
§
Explain the strategy for
database optimization presented in the Performance Optimization Model.
§
Explain the importance of
schema design in database optimization.
§
Describe the strategic use of
natural and surrogate keys and their roles in schema optimization.
§
Describe responsible
denormalization and the role of this strategy in schema optimization.
§
Describe generalization and the
role of this strategy in schema optimization.
§
Explain how to modify the
database schema.
§
Normalize a database schema for
optimization.
§
Generalize a database schema
for optimization.
§
Denormalize a database schema
for optimization and clean up the schema.
§
Compare the solution and
determine performance.
Unit 3: Optimizing Queries for Performance
In this unit students experience optimizing and tuning queries to
improve performance. In the lab, students will optimize stored procedures, views, and non-cursor
aggregate queries to improve database performance and user experience.
Each query that is optimized improves the overall system because the query will use fewer resources, freeing up those resources for other queries, and reducing the amount of locking done by the query. The domino effect is profound.
|
Topics |
|
§ What Is Query Logical Flow? § Demonstration: How the Query Optimizer Processes Queries §
Considerations to Take When
Using Subqueries §
Guidelines for Building
Efficient Queries |
|
Lab: Optimizing Queries for Performance |
|
§
Optimizing the Performance of
Stored Procedures §
Optimizing the Performance of
Views § Optimizing the Performance of Non-Cursor Aggregate Queries §
Recording Performance Times |
After completing this unit, students will be able to:
§
Explain the utility of query
logical flow in query optimization.
§
Describe how the query
optimizer processes queries.
§
Discuss considerations to take
when using subqueries.
§
Describe guidelines for
building efficient queries.
§
Optimize the performance of stored
procedures.
§
Optimize the performance of
views.
§
Optimize the performance of
non-cursor aggregate queries.
§ Record performance times.
Unit 4: Refactoring Cursors into Queries
In this unit, students will work with strategies for refactoring cursors into queries. In the lab, students will work to optimize a database by replacing slow iterative code with faster set-based code.
|
Topics |
|
§ Cursor Usage and Performance § Strategies for Refactoring Cursors §
Using PIVOT and Common Table
Expressions |
|
Lab: Refactoring Cursors into Queries |
|
§
Refactoring the
pMembershipCategory Cursor §
Refactoring the
pCommunityImpact Cursor §
Refactoring the pMemberInvitation Cursor §
Determining Performance |
After completing this unit, students will be able to:
§
Explain cursor usage and performance.
§
Describe strategies used to
refactor cursors.
§
Explain the use of PIVOT and
Common Table Expressions.
§
Refactor the
pMembershipCategory cursor.
§
Refactor the pCommunityImpact
cursor.
§
Refactor the pMemberInvitation
cursor.
§
Test queries for performance.
Unit 5: Optimizing an Indexing Strategy
In this unit, students will work on optimizing indexing strategies.
Students will work with a given database to add and delete indexes, by
providing the optimum bridge between the query and the data without any redundancies.
|
Topics |
|
§ How SQL Server Stores and Accesses Data §
Considerations for Using Indexes § Nonclustered Index Design § Best Use of Clustered Indexes §
How to Document an Indexing
Strategy |
|
Lab: Optimizing an Indexing Strategy |
|
§
Identifying Tables to
Optimize Based on Slow-Running Code §
Designing and Implementing
Indexes § Recording Performance Times |
After completing this unit, students will be able to:
§
Explain how SQL Server stores
and accesses data.
§
Describe considerations for
using indexes in database optimization.
§
Explain guidelines for
nonclustered index design and usage.
§
Describe the best use of
clustered indexes as they relate to optimization.
§
Describe how to document an
indexing strategy.
§
Identify tables to optimize
based on slow-running code.
§
Design and implement indexes.
§
Record performance times.
Unit 6: Managing Concurrency
This unit provides students with the opportunity to work with
concurrency management. Students will look for concurrency issues and then
solve them by optimizing transactions and adjusting the transaction isolation level.
|
Topics |
|
§ Transaction Isolation Levels §
Demonstration: Transaction
Isolation Levels § Guidelines to Reduce Locking and Blocking |
|
Lab: Managing Concurrency |
|
§
Identifying Code That Has
Locking and Blocking Issues §
Reducing Concurrency Issues § Calculating the Overall Performance Gain |
After completing this unit, students will be able to:
§
Explain transaction isolation
levels.
§
List guidelines for reducing
locking and blocking.
§
Identify code that has locking
and blocking issues.
§
Reduce concurrency issues.
§
Calculate the overall
performance gain.
|
© 2005 Microsoft Corporation. All rights reserved. Some elements of this
course syllabus are subject to change. This syllabus is for informational
purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS
SUMMARY. Microsoft is a registered trademark or trademark of Microsoft
Corporation in the |