Presentation is loading. Please wait.

Presentation is loading. Please wait.

Jon JahrenJon Jahren Produktsjef, Microsoft NorgeProduktsjef, Microsoft Norge

Similar presentations


Presentation on theme: "Jon JahrenJon Jahren Produktsjef, Microsoft NorgeProduktsjef, Microsoft Norge"— Presentation transcript:

1 Jon JahrenJon Jahren Produktsjef, Microsoft NorgeProduktsjef, Microsoft Norge jonjah@microsoft.com

2 Microsoft Confidential New and changed optimization features with SP2 Best Practices Analyzer DMV & DMVStats Performance Dashboard Plan Guides LINQ VSTS DBPro, aka “Datadude”

3 Microsoft Confidential Customer Pain Points Difficulty administrating multiple instances Desire to customize Management Studio Need for a best practices tool SQL Server 2000 “take away” features 3 New Features Multi-instance administration Custom Reports in Management Studio SQL Server 2005 Best Practices Analyzer VarDecimal storage format (EE) 2 major improvements Script Generation Copy Database

4 Microsoft Confidential Custom reports Open your own reports without installing SSRS Standard Reports improved scalability New Disk Usage reports have been tested on SAP Improved discoverability Reports can be accessed from Object Explorer context menu Improved usability Open reports in new window Compare reports List of most recently used

5 Microsoft Confidential Reduces time spent in diagnosing root cause of problems Scans multiple servers remotely Helps identify potential problems as defined by Microsoft Educates users on best practices Provides interactive reporting Each rule has corresponding article

6 Microsoft Confidential 6 The SQL Server 2005 Management Pack monitors performance and availability of: SQL Server agent Database health and transaction log free space SQL Server clustering and named instances Local and remote connectivity Security SQL Server replication

7 Microsoft Confidential 7 Management Pack Benefits: Granular discovery, monitoring and reporting of SQL Server components Client perspective of SQL database availability Database space and growth monitoring Replication discovery and monitoring SQL agent job discovery and monitoring Blocking processes, long running jobs and general performance monitoring of SQL SQL Configuration monitoring Granularity to change monitoring behavior on a per object level

8 Microsoft Confidential Perfmon SQL Trace (profiler) DBCC DMVs and DMFs DAC (Dedicate Admin Connection) DTA (Database Tuning Advisor) Physical Dump

9 Microsoft Confidential Dynamic Management Views Also known as DMVs Expose server state as a relational rowset State is generally in memory (not persisted) Not new. DMVs in SQL2000 (sysprocesses) Low overhead (approx 2%) Many DMVs expose information that needs to be maintained anyway What’s new for SQL2005? Many more DMVs and a new framework

10 Microsoft Confidential General Server DMVs and DMFs Server level dm_exec_* Execution of user code and associated connections dm_os_* low level system (server- wide) info such as memory, locking & scheduling dm_tran_* Transactions & isolation dm_io_* Input/Output on network and disks dm_db_* Databases and database objects Component level dm_repl_* Replication dm_broker_* SQL Service Broker dm_fts_* Full Text Search dm_qn_* Query Notifications dm_clr_* CLR execution of managed code

11 Microsoft Confidential DMV Examples sys,.dm_io_virtual_file_stats Sys.dm_os_scheduler Sys.dm_tran_active_transactions Sys.dm_exec_query_stats sys,.dm_exec_requests Sys.dm_db_index_usage_statistics sys.dm_db_index_operational_stats Sys.dm_os_wait_stats

12 Microsoft Confidential How to use DMVs Challenge Need to know a lot about SQL Internals Need to apply a specific methodology to identify problems Solution Use scripts for common performance issues Use DMVstats Tool

13 Microsoft Confidential What is DMVstats? DMV collection, analysis, and reporting application Data collection managed by SQLAgent jobs DMVstatsDB - performance data warehouse repository of DMV statistics Analysis and reporting provided by DMVstats Reports

14 Microsoft Confidential DMVstats Objectives Provide Expert Guidance from the experience, lessons learned, and best practices from Microsoft's SQL Server Development Customer Team. Methodology: Provides performance analysis by using the proven Waits and Queues Educate user

15 Microsoft Confidential SQL Server Best Practices Site On TechNet Get the real-world guidelines, expert tips, and rock-solid guidance to take your SQL Server implementation to the next level. http://www.microsoft.com/technet/prodtechnol/sql/bestpracti ce/default.mspx Contents Technical Whitepapers ToolBox Top 10 Lists Ask a Question Other Resources SQLCAT Blog: http://blogs.msdn.com/sqlcat/ SQL ISV PM Blog: http://blogs.msdn.com/mssqlisv/

16 Microsoft Confidential SQL Server has three types are hints JOIN hint Use loop, hash, merge to join table Can specify side for REMOTE join QUERY hint Many of these TABLE hint Use table scan Use one or more indexes Locking hints

17 Microsoft Confidential { HASH | ORDER } GROUP { CONCAT | HASH | MERGE } UNION { LOOP | MERGE | HASH } JOIN FAST number_rows FORCE ORDER MAXDOP number_of_processors OPTIMIZE FOR ( @variable_name = literal_constant [,…n ]] PARAMETERIZATION { SIMPLE | FORCED } RECOMPILE ROBUST PLAN KEEP PLAN KEEPFIXED PLAN EXPAND VIEWS MAXRECURSION number USE PLAN N'xml_plan'

18 Microsoft Confidential Query hints cannot be applied if you don’t have access to the source code Dynamically generated Purchased package Query hints tie the hint to the source code No straightforward way to disable Always using procedures helps this Enter plan guides…

19 Microsoft Confidential Plan guide is a named database object Only available in Standard and Enterprise Associates a hint with a query Lives at database scope Defined and maintained through system procs sp_create_plan_guide Can be enabled or disabled sp_control_plan_guide sp_create and sp_control flush appropriate query cache entries sys.plan_guides holds plan guide metadata

20 Microsoft Confidential Query must match exactly Including whitespace and CR/LF Use profiler to capture query Right click and choose Extract Command Paste command into sp_create_plan_guide Use XML query plan to ensure its working Plan guide used is in query plan Enabling plan guides clears plan cache

21 Microsoft Confidential If the existing query uses a hint, the hint text must be specified in the plan guide The plan guide hint(s) takes the place of the hint specified in the query You can include the original hint in the plan guide if additive hints are desired

22 Microsoft Confidential Plan guides "pin" an object, i.e. can't change until you drop the plan guide Plan guides can be done anywhere you use a query hint SELECT, INSERT, UPDATE, DELETE Plan forcing - only SELECT, SELECT INTO Text must match character for character Cannot be used with encrypted objects or DDL triggers A "few dozen" queries is limit of plan guides Do not hand-edit XML showplans

23 Microsoft Confidential Specified via USE PLAN query hint Capture XML showplan Paste into sp_create_plan_guide Or paste into query directly Plan guide not required Make sure all single quotes are escaped Plan forcing works with SELECT SELECT INTO

24 Microsoft Confidential Isn’t plan forcing a security problem? No, it must be A plan that matches the query A plan that the optimizer would normally consider Is plan forcing faster because plan doesn’t need to be chosen? No The plan must be parsed and checked It’s actually a little slower (optimization times are slightly increased) Should I turn off statistics if I force plans? No, stats are used for memory estimates

25 Microsoft Confidential Objects XML.NET Language Integrated Query C# 3.0VB 9.0Others… Relational LINQ to Objects LINQ to SQL LINQ to XML LINQ to Entities LINQ to DataSets

26 Microsoft Confidential SqlConnection c = new SqlConnection(…); c.Open(); SqlCommand cmd = new SqlCommand( @"SELECT c.Name, c.Phone FROM Customers c WHERE c.City = @p0"); cmd.Parameters.AddWithValue("@p0", "London“); DataReader dr = c.Execute(cmd); while (dr.Read()) { string name = dr.GetString(0); string phone = dr.GetString(1); DateTime date = dr.GetDateTime(2); } dr.Close(); Queries in quotes Loosely bound arguments Loosely typed result sets No compile time checks

27 Microsoft Confidential public class Customer { … } public class Northwind : DataContext { public Table Customers; … } Northwind db = new Northwind(…); var contacts = from c in db.Customers where c.City == "London" select new { c.Name, c.Phone }; Classes describe data Strongly typed connections Integrated query syntax Strongly typed results Tables are like collections

28 Microsoft Confidential Application SQL Server LINQ to SQL from c in db.Customers where c.City == "London" select c.CompanyName LINQ Query SQL Query SELECT CompanyName FROM Cust WHERE City = 'London' Rows ObjectsSubmitChanges() DML or SProcs db.Customers.Add(c1); c2.City = “Seattle"; db.Customers.Remove(c3); INSERT INTO Cust … UPDATE Cust … DELETE FROM Cust …

29 Microsoft Confidential Database SchemaClass Schema

30 Microsoft Confidential Other names you might hear: Data Dude K2 TSData DBPro

31 Microsoft Confidential Incorporate the Database Professional into the software lifecycle and provide them with a foundation for change management and process integration. Change Management Project Based Development Project Model in Visual Studio with Support for Team Collaboration via Team Foundation Server Automated Change Support Rename Refactoring, Schema & Data Comparison Tools, and Version Control Database Unit Testing Leverages the existing Test Project Infrastructure with support for data generation Build / Deployment MSBuild and Team Build integration

32 Microsoft Confidential Team Database Development with Data Dude Writes Tests Writes DB Code Refactors Runs Tests Checks In Works with other developers to integrate Reviews Changes Compares Updates to Production Builds Deploy Package Deploys to Production Creates New DB Project Reverse Engineers DB to Project Creates Data Generation Plan Manage Develop Deploy DBADB DEVELOPERDBA

33 Microsoft Confidential Schema Change now managed in VSTS and TFS Production Database is now “One version of the truth” only for Data DBA doesn’t have access to changes until he/she has deploy or reject choice “One Version of the truth for Schema” is kept under Source Control Changes can be rolled out in a scheduled, managed way Scripts allow administrators to manage change updates Production Database SQL Server 2005 Management Studio TuningMonitoring “One Version of the Truth” for “One Version of the Truth” for Data “One Version of the Truth” for Schema OfflineOffline Under Source ControlUnder Source Control Schema Schema Changes

34 Microsoft Confidential Rich engine allows for sample data generation Useful because it’s often not feasible (or even legal) to use production data Allows for repeatable test scenarios Support for different types of generators Simple for standard data types Complex for regular expressions, foregin key lookup, data bound And yes, you can write your own

35 Microsoft Confidential New and changed optimization features with SP2 Best Practices Analyzer DMV & DMVStats Performance Dashboard Plan Guides LINQ VSTS DBPro, aka “Datadude”


Download ppt "Jon JahrenJon Jahren Produktsjef, Microsoft NorgeProduktsjef, Microsoft Norge"

Similar presentations


Ads by Google