602 Chapter13•PerformanceTuning DMVs can be server-scoped or database-scoped reflecting the data tracked Ü within the DMV. DMVs run continually in the background with a very low overhead, data Ü provided is either cumulative (since last service restart) or a snapshot view. Partitioning Partitioning can be used to split a large table into a series of smaller tables Ü transparent to the application. Horizontal partitioning can be used to split a table into several smaller Ü tables with all columns and a smaller number of rows (often by date). Vertical partitioning divides a large table into several smaller tables each Ü with all rows, but a subset of columns. Performance Data Collection (Data Collector) The Performance Data Collection allows collection of performance data Ü from a number of servers to a central data warehouse for analysis and reporting. Performance data is stored in the Management Data Warehouse (MDW) Ü which is a relational database intended to be an organization-wide reposi- tory for performance data. Data collection is the process of harvesting performance data from target Ü servers to store in the MDW. Resource Governor Resource Governor provides capability to identify inbound connections to Ü SQL Server and provide these connections with minimum and maximum resource (Memory, CPU) allocation. Resource pools are used to control physical server resources, while work- Ü load groups map users groups to resource pools the classifier functions are used to assign users to workload groups. The Dedicated Admin Connection (DAC) is not subject to the resource Ü governor. Performance Tuning • Chapter 13 603 Exam Objectives Frequently Asked Questions Q: What’s happening when SQL Profiler reports missing events? A: This happens occasionally with very busy servers when tracing to a table or to SQL Profiler. In this situation the SQL Profiler tool is unable to keep up with the volume of events that are generated. Consider using a server side trace and saving the trace to a flat file, local to the database server. Q: How big will the trace file grow? A: The size of trace files is determined by the workload, events, and columns included in the trace definition. A very busy server with only a few events defined can produce a file as large as a quiet server with many events included. Be sure to monitor the growth of trace files to ensure they don’t fill any drives, and if you’re leaving a trace unattended (e.g., overnight) ensure there is plenty of disk space to include activities such as nightly maintenance or data loads. 604 Chapter13•PerformanceTuning Self Test 1. You’re the DBA for a sales and marketing organization that has a high rate of data change (lots of INSERTS and DELETES). Over the past few weeks the SQL server has gradually become slower. Which DMV could help identify the cause? A. Sys.dm_os_schedulers B. Sys.dm_os_slow_tasks C. Sys.dm_db_index_physical_stats D. Sys.dm_exec_requests 2. Which of the following could be used within a function by Resource Governor to classify incoming sessions? A. IP Address B. Username C. Server Role Membership D. Hostname 3. You’ve recently enabled Resource Governor to ensure the Finance and HR departments each receive a fair share of CPU and memory on a consolidated SQL Server. Since Resource Governor has been operating, some users have experienced connection timeouts and you suspect the classifier function may be the cause. How could you identify the cause? A. Run SQL Profiler B. Connect using Dedicated Admin Connection C. Capture Performance Monitor data D. Reboot the server and see if problem recurs 4. You’re troubleshooting a slow running problem and you’d like to see which indexes, if any, are being used by the slow query. You’re configuring a SQL profiler trace. Which events should you include to see the actual execution plan in XML? A. Showplan XML Statistics Profile B. SQL:BatchCompleted C. Showplan XML D. RPC:Completed PerformanceTuning•Chapter13 605 5. Users complain that the database server is slow to respond or causes timeouts, and you’ve been running a server-side trace capturing details of query perfor- mance. The server is busy and you’ve generated 10 × 1 GB trace files. What’s the best way to find queries with the longest duration? A. Open each trace file in Profiler and find longest duration. B. Open the trace in Excel and sort by duration. C. Use fn_trace_gettable to load the data into a table, analyze with TSQL queries. D. Run the trace again with a filter. 6. You’re responsible for maintenance for a mission-critical database that is 650 GB in size, with a particularly large sales order table. The nightly index maintenance scripts are fully optimized but regularly run longer than the maintenance window. How could you resolve this with minimal impact to the business? A. Delete old data from the sales order table. B. Separate sales data into separate databases, one for each calendar year. C. Don’t carry out index maintenance. D. Implement table partitioning. 7. You’re responsible for managing a database that uses table partitioning for a stock trading firm. Performance on the partition storing most recent trades has started to degrade and you’d like to begin a new partition. Which statement should you use? A. ALTER PARTION FUNCTION… SPLIT B. ALTER TABLE … SWITCH C. ALTER TABLE … SPLIT D. Denormalize the table to 5th Normal Form 8. When a new SQL Server session is started that meets none of the criteria defined in the Classifier function, to which resource pool is the session assigned? A. Internal B. Default C. Custom-1 D. None 606 Chapter13•PerformanceTuning 9. You’re the Administrator for a SQL Server used by a number of departments within your organization. At the end of each month the Accounts department runs a number of reports that calculate complex ratios and analytics. During this time other users frequently receive timeouts and poor performance. What’s the best solution to limit the impact of these CPU-intensive reports run by Accounts? A. Implement table partitioning. B. Separate data and log files. C. Use Resource Governor. D. Request Accounting users run reports only at night. 10. You’re a Systems Engineer responsible for SQL Server, and a case had been escalated via the helpdesk where a user reported an exception in an applica- tion—the error included deadlock victim. You’d like to implement monitoring to capture details of the deadlocked processes and locks held with minimum overhead. Should you: A. Start a SQL Profiler Trace. B. Capture Lock\Deadlocks per second with Windows System Monitor. C. Enable trace flag 1222. D. Review the sys.dm_tran_locks DMV. 11. A developer is using locking hints within a stored procedure and has some questions about lock escalation. You describe lock escalation as the time when SQL Server: A. Changes down from table locks to row locks. B. Changes from SHARED to UPDATE locks. C. Changes up from row lock to table locks. D. Changes from an UPDATE lock to EXCLUSIVE lock. 12. You’re working with an external vendor on a patch to their application. They’ve applied the patch to the test environment and would like to simulate some production-like workload to assess the success of the patch. You’ve decided to capture a SQL trace. Which trace template will you use? A. TSQL_Replay B. Tuning . with the volume of events that are generated. Consider using a server side trace and saving the trace to a flat file, local to the database server. Q: How big will the trace file grow? A: The. Denormalize the table to 5th Normal Form 8. When a new SQL Server session is started that meets none of the criteria defined in the Classifier function, to which resource pool is the session. vendor on a patch to their application. They’ve applied the patch to the test environment and would like to simulate some production-like workload to assess the success of the patch. You’ve decided