Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Microsoft SQL Server 2012 Performance Tuning Cookbook
Microsoft SQL Server 2012 Performance Tuning Cookbook

Microsoft SQL Server 2012 Performance Tuning Cookbook: With this book you'll learn all you need to know about performance monitoring, tuning, and management for SQL Server 2012. Includes a host of recipes and screenshots to help you say goodbye to slow running applications.

eBook
$35.98 $39.99
Paperback
$65.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Microsoft SQL Server 2012 Performance Tuning Cookbook

Chapter 2. Tuning with Database Engine Tuning Advisor

In this chapter we will cover:

  • Analyzing queries using Database Engine Tuning Advisor

  • Running Database Engine Tuning Advisor for Workload

  • Executing Database Tuning Advisor from command prompt

Introduction


Database Engine Tuning Advisor (DTA) suggests ways to tune the database by analyzing the Workload provided. DTA helps in creating an efficient index, an indexed view (if it's supported by the SQL Server Edition you are using), statistics, and partitions. DTA can give efficient suggestions only if you have created proper workload with sufficient data. For further details of creating workload, refer Creating a trace or workload recipe of Chapter 1, Mastering SQL Trace Using Profiler.

Studying an Estimated execution plan (covered in Chapter 5, Monitoring with Execution Plans) of query from Query Editor to find out the bottleneck and resolve it needs knowledge of the database structure as well as good command over performance tuning, whereas DTA offers a very simple solution to this. Just collect the proper workload, give it to DTA and it will analyze that Workload for you and suggests you the ways for tuning.

Sometimes it happens that we tune one query by creating/removing an index...

Analyzing queries using Database Engine Tuning Advisor


There are few different ways that can help you in providing workload to DTA. One of the popular ways is to ask DTA about the query you are designing at the moment for performance point of view, so that DTA can analyze the query and provide suggestions, if any.

Getting ready

We will need two tables to demonstrate this recipe. Here is the script to create the same:

USE AdventureWorks2012
GO
IF OBJECT_ID('ProductDemo') IS NOT NULL
DROP TABLE ProductDemo
GO
IF OBJECT_ID('ProductModelDemo') IS NOT NULL
DROP TABLE ProductModelDemo
GO
select * into ProductModelDemo from Production.ProductModel
select * into ProductDemo from Production.Product
GO

We have just created two tables, named ProductDemo and ProductModelDemo, which don't have any index or statistics right now.

How to do it...

Now here is the query we want to execute and tune if possible:

SELECT
P.ProductID
,P.ProductModelID
FROM
ProductDemo AS P
JOIN
ProductModelDemo AS PM
ON
P.ProductModelID...

Running Database Engine Tuning Advisor for workload


Trace is a session during which the events are captured and event data is collected. SQL Server supports a few formats for saving this collected trace data, which is known as a workload. We can save trace data (a workload) in one of the following formats:

  • A trace file with .trc extension name

  • A trace file in XML format with .xml extension name

  • A trace table in an SQL Server database

We are going to use trace file .trc for this recipe. For detailed information regarding trace, workload, and different events of trace in profiler, refer Creating a trace or workload recipe in Chapter 1.

In this recipe, we will create a trace with SQL Server Profiler; execute some queries that will be captured in running profiler trace file and load that trace file in Database Engine Tuning tool to analyze the workload.

Tip

It is recommended to use server-side trace over profiler use on a production server as profiler can consume lot of network bandwidth resources...

Executing Database Tuning Advisor from command prompt


There is a command prompt version of Database Engine Tuning Advisor, which is known as DTA. Like a Database Engine Tuning Advisor, DTA also analyses the workload given to it in the form of trace file, table, or query. There is no difference in tuning activity or the suggestions it provides. The visible difference is that Database Engine Tuning Advisor provides GUI and DTA provides a traditional approach. Apart from that, DTA gives you the liberty to provide XML file, if you don't like to type down all parameter on command line.

If you have the same database structure in your development environment as you have in production server with very less data in development environment, you can copy the production instance's index statistics and metadata. This effectively recreates a target environment without the need to migrate a volume of data onto a development server. DTA creates a shell database that you can tune by using the TestServer...

Left arrow icon Right arrow icon

Key benefits

  • Learn about the performance tuning needs for SQL Server 2012 with this book and ebook
  • Diagnose problems when they arise and employ tricks to prevent them
  • Explore various aspects that affect performance by following the clear recipes

Description

As a DBA you must have encountered a slow running application on SQL Server, but there are various factors that could be affecting the performance. If you find yourself in this situation, don't wait, pick up this book and start working towards improving performance of your SQL Server 2012. SQL Server 2012 Performance Tuning Cookbook is divided into three major parts -- Performance Monitoring, Performance Tuning, and Performance Management--that are mandatory to deal with performance in any capacity. SQL Server 2012 Performance Tuning Cookbook offers a great way to manage performance with effective, concise, and practical recipes. You will learn how to diagnose performance issues, fix them, and take precaution to avoid common mistakes. Each recipe given in this book is an individual task that will address different performance aspects to take your SQL Server's Performance to a higher level.The first part of this book covers Monitoring with SQL Server Profiler, DTA, System statistical function, SPs with DBCC commands, Resource Monitor & Reliability, and Performance Monitor and Execution Plan. The second part of the book offers Execution Plan, Dynamic Management Views, and Dynamic Management Functions, SQL Server Cache and Stored Procedure Recompilations, Indexes, Important ways to write effective TSQL, Statistics, Table and Index Partitioning, Advanced Query tuning with Query Hints and Plan Guide, Dealing with Locking, Blocking and Deadlocking and Configuring SQL Server for optimization to boost performance.The third and final part gives you knowledge of performance management with help of Policy Based Management and Management with Resource Governor.

Who is this book for?

SQL Server 2012 Performance Tuning Cookbook is aimed at SQL Server Database Developers, DBAs, and Database Architects who are working in any capacity to achieve optimal performance. However, basic knowledge of SQL Server is expected, but professionals who want to get hands-on with performance tuning and have not worked on tuning the SQL Server for performance will find this book helpful.

What you will learn

  • Monitoring SQL Server Performance with Profiler, Execution Plan, and system statistical function
  • Finding performance bottleneck with the help of Resource Monitor and DTA
  • Creating and Managing Indexes efficiently to boost performance
  • Creating and Managing Partition efficiently
  • Managing database files efficiently
  • Planning Guide and Query Hints
  • Dealing with locking, blocking, and deadlocking
  • Configuring SQL Server instance option for achieving performance benefit
  • Managing Performance with Policy based management and Resource Governor

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jul 26, 2012
Length: 478 pages
Edition : 1st
Language : English
ISBN-13 : 9781849685740
Vendor :
Microsoft
Languages :
Concepts :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Jul 26, 2012
Length: 478 pages
Edition : 1st
Language : English
ISBN-13 : 9781849685740
Vendor :
Microsoft
Languages :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 180.97
Microsoft SQL Server 2012 Performance Tuning Cookbook
$65.99
Microsoft SQL Server 2012 Integration Services: An Expert Cookbook
$48.99
SQL Server 2012 with PowerShell V3 Cookbook
$65.99
Total $ 180.97 Stars icon

Table of Contents

19 Chapters
Mastering SQL Trace Using Profiler Chevron down icon Chevron up icon
Tuning with Database Engine Tuning Advisor Chevron down icon Chevron up icon
System Statistical Functions, Stored Procedures, and the DBCC SQLPERF Command Chevron down icon Chevron up icon
Resource Monitor and Performance Monitor Chevron down icon Chevron up icon
Monitoring with Execution Plans Chevron down icon Chevron up icon
Tuning with Execution Plans Chevron down icon Chevron up icon
Dynamic Management Views and Dynamic Management Functions Chevron down icon Chevron up icon
SQL Server Cache and Stored Procedure Recompilations Chevron down icon Chevron up icon
Implementing Indexes Chevron down icon Chevron up icon
Maintaining Indexes Chevron down icon Chevron up icon
Points to Consider While Writing Queries Chevron down icon Chevron up icon
Statistics in SQL Server Chevron down icon Chevron up icon
Table and Index Partitioning Chevron down icon Chevron up icon
Implementing Physical Database Structure Chevron down icon Chevron up icon
Advanced Query Tuning Hints and Plan Guides Chevron down icon Chevron up icon
Dealing with Locking, Blocking, and Deadlocking Chevron down icon Chevron up icon
Configuring SQL Server for Optimization Chevron down icon Chevron up icon
Policy-based Management Chevron down icon Chevron up icon
Resource Management with Resource Governor Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
(3 Ratings)
5 star 0%
4 star 0%
3 star 100%
2 star 0%
1 star 0%
Ian Stirk Oct 28, 2013
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
Hi,I have written a detailed chapter-by-chapter review of this book on www DOT i-programmer DOT info, the first and last parts of this review are given here. For my review of all chapters, search i-programmer DOT info for STIRK together with the book's title.Each recipe in this collection is largely self-contained, making it easy to provide a targeted approach. This is good if you know what you're looking for, but often when you're starting out, you don't. Experience helps, so does reading the whole book.Each chapter starts with a short introduction to the topic, and contains between three and eight recipes. Each recipe contains sections for:- getting ready- how to do it- how it works- there's moreMost recipes are run against the freely downloadable Adventure Works 2012 database, this makes it easy to follow along with the recipes yourself. Below is a chapter-by-chapter exploration of the topics covered.Chapter 1 Mastering SQL Trace Using ProfilerAlthough SQL Server Profiler is deprecated, meaning it will be removed from future versions of SQL Server, it is a well known and much used tool for troubleshooting problems. The recipes here walk you through setting up a trace, filtering events, and detecting slow queries - all via the GUI. Additionally, the T-SQL equivalent is also provided. Overall the chapter is easy to read, explains things very well, with more than enough detail to get you started troubleshooting database problems....ConclusionThis is a wide-ranging book, with sufficient instruction to get most SQL developers/DBAs started on investigating performance problems. It's a very practical book, typically providing detailed step-by-step walkthroughs for each recipe/topic, and makes good use of screenshots.There's some nice incidental information provided along with the recipes, and plenty of pointers on where to find further information. Because the topics are largely distinct, there is limited interlinking of recipes/topics.Although the book purports to relate to SQL Server 2012, much of it is equally applicable to SQL Server 2005 and 2008.Unfortunately, the book contains several areas of substandard English grammar. If you can tolerate this, the book can be a good read. Personally I think the book's editors should have been fired!
Amazon Verified review Amazon
M. Goldshteyn Aug 22, 2012
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
I have skimmed through the book using Amazon's "Search inside" feature. There are many useful tips, but reading is made difficult by the fact that the English grammar used throughout the book is often improper. It is clear that not enough editing went into the book or perhaps the author's use of English was so horrid that the editor(s) gave up at some point and "let it ride."
Amazon Verified review Amazon
Petr Smirnov Nov 22, 2016
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
Very good, but obsolette (now we have SQL 2016)
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.