Tech Ed North America 2010 8/23/2018 1:32 AM Required Slide

Slides:



Advertisements
Similar presentations
MIX 09 4/15/ :14 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Advertisements

Session 1.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.

demo © 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
demo Demo.
demo QueryForeign KeyInstance /sm:body()/x:Order/x:Delivery/y:TrackingId1Z
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks.
© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.

How We Do Language Design at Microsoft (C#, Visual Basic, F#)
Tech·Ed  North America /11/ :01 AM SESSION CODE: DEV405
6/12/ :53 PM DEV311 Deep Dive into Microsoft Visual Studio Team Foundation Server 2010 Reporting Steven Borg, Principal ALM Consultant Northwest.
9/11/2018 5:53 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
MDOP: Advanced Group Policy Management 4.0
Tech Ed North America /13/ :13 AM Required Slide
Introduction to SQL Server Management for the Non-DBA
Microsoft Visual Studio IDE Futures
Overview of Social Computing in Microsoft SharePoint 2010
Customer Experiences With Business Intelligence
Implementing RESTful Services Using the Microsoft .NET Framework
Sysinternals Tutorials
T-SQL Power! The OVER Clause: Your Key to No-Sweat Problem Solving
Title of Presentation 11/22/2018 3:34 PM
What’s New In ASP.NET MVC 2
Advanced Dashboard Creation Using Microsoft SharePoint Server 2010
TechEd /24/2018 8:21 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered.
Jason Zander Unplugged
Branching and Merging Practices
Title of Presentation 12/2/2018 3:48 PM
High Availability: A Contrarian View
Business Intelligence Overview: Decisions, Decisions, Decisions
Manage Your Enterprise from a Single Seat: Windows PowerShell Remoting
Better Together: Secure SQL Server on Secure Windows
Windows 7 Deployment en Masse
Best Practices: Creating OData Services using WCF Data Services
Team Foundation Server 2010 for Everyone
Introducing Microsoft SQL Server 2008 R2 Master Data Services
Authoring for Microsoft Silverlight 4 with Microsoft Expression Blend
Tech Ed North America /1/ :36 AM Required Slide
Tech Ed North America /1/2019 2:58 AM Required Slide
Tech·Ed North America /17/2019 1:47 AM
Sunil Agarwal | Principal Program Manager
TechEd /18/2019 2:43 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
Microsoft SharePoint Conference 2009 Jon Flanders
Building Silverlight Apps with RIA Services
Developing Advanced Applications with Windows Azure
TechEd /28/2019 7:27 AM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
Tech Ed North America /12/2019 6:45 AM Required Slide
Silverlight Debugging
8/04/2019 9:13 PM © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
A Lap Around Internet Explorer 9 For Developers
Виктор Хаджийски Катедра “Металургия на желязото и металолеене”
2010 Microsoft BI Conference
Hack-proofing your Clients using Windows 7 Security!
How and When to Use MEF: Too Much Is Never Enough
Title of Presentation 5/12/ :53 PM
Шитманов Дархан Қаражанұлы Тарих пәнінің
Lap Around the Windows Azure Platform
Code First Development in Microsoft ADO.NET Entity Framework 4.1
Building BI applications using PowerPivot for Excel
Title of Presentation 5/24/2019 1:26 PM
Tech·Ed North America /6/2019 7:10 PM
Title of Presentation 7/24/2019 8:53 PM
TechEd /30/2019 7:18 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
Tech Ed North America /6/2019 2:07 PM Required Slide
Tech·Ed North America /7/2019 2:30 PM
TechEd /5/2019 2:08 AM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
Presentation transcript:

Tech Ed North America 2010 8/23/2018 1:32 AM Required Slide SESSION CODE: DAT315 Strategies to Get Maximum Concurrency for Your Workload in Microsoft SQL Server Sunil Agarwal Senior Program Manager sunila@microsoft.com Microsoft Corporation © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Goals Concurrency challenges with applications Identifying and troubleshooting concurrency issues Strategies for creating applications for higher concurrency

Common Concurrency Issues with Applications Wrong transaction isolation level Incorrect locking granularity Missing Indexes Accessing large dataset leading to lock escalation Long running transactions User interactions in active transaction Accessing objects in reverse order across transactions Application induced hotspots

Isolation Levels SQL-Standard specifies four isolation levels SQL Server has implemented these all along using lock based implementation. Read Uncommitted Most concurrent, least restrictive, more anomalies are possible SQL Server: No share locks Read Committed Only reads committed data. Data can change over multiple reads SQL Server: Data access only after acquiring S-lock. Lock released when moved to next row/page Repeatable Read Read rows don’t change. Phantom rows can appear SQL Server: Data access only after acquiring S-lock. Lock released at the end of the transaction Serializable Least concurrent, most restrictive, always ‘correct’ Isolation-levels impact the concurrency SQL2005 introduced RCSI (Read Committed Snapshot) and SI (Snapshot Isolation) using non-blocking implementation.

Reader Writer Blocking Data Page Tran2 (Select) Tran1 (Update) Row-1 Row-1 S-Lock Blocked X-Lock

Read Committed Snapshot Statement-Level ‘Snapshot Isolation’ New “flavor” of read committed Turn ON/OFF on a database Readers see committed values as of beginning of statement Writers do not block Readers Readers do not block Writers Writers do block writers Can greatly reduce locking / deadlocking without changing applications

Snapshot Isolation Transaction level ‘Snapshot Isolation’ SQL Server proprietary isolation level Turn ON/OFF on a database Available since SQL Server 2005 Readers see committed values as of beginning of the Transaction Writers do not block Readers Readers do not block Writers Writers do block writers Can greatly reduce locking / deadlocking but requires application change Set Transaction Isolation level Snapshot Scenario: Cross query data view consistency

Locking Granularity Small lock granules, such as rows: Maximize concurrency Are expensive to maintain(require many lock manager calls). Approx 100 byte overhead Large granules, such as tables: Expensive in terms of concurrency Cheap to acquire (few lock manager calls) Multi-granular lock protocols allow us to have it both ways Decided at run-time using internal heuristic Can be over-ridden using sp_indexoption or locking hint Lock Escalation

Lock Modes Common locking modes Mode Description S Share - used for reading X Exclusive - typically used for writing (insert, update, delete) U Update - used to evaluate prior to writing IS Intent Share - share locking at finer level IX Intent Exclusive - X locking at finer level BU Bulk Update. Used in Bulk Load SCH-S Schema Share SCH-M Schema modify lock

Locking Hints Locking hints are used to Lock duration Change locking behavior at statement level Example: TABLOCK, UPDLOCK To change isolation level at statement level Examples: NOLOCK, READPAST, TABLOCK, READCOMMITTED, REPEATABLEREAD Lock duration Depends on isolation level it is acquired at.

Blocking Detection and Troubleshooting Tech Ed North America 2010 8/23/2018 1:32 AM Blocking Detection and Troubleshooting Sunil Agarwal Senior Program Manager Microsoft DEMO © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Lock Escalation Lock Escalation HOBT Page Row T1: IX T1: X T1: IX

Lock Escalation Converting finer-grain locks to coarse grain locks. Row to Table Page to Table. No escalation from Row to Page Benefits Reduced locking overhead Reduces Memory requirement. Each lock structure is 100 bytes Impedes concurrency Triggered when Number of locks acquired on a rowset > 5000. Periodically after that It is not based on the locks in a transaction Memory pressure

Lock Escalation… Cont Controlling Lock Escalation TF-1211 disables lock escalation for the instance. SQL Server can run out of lock memory TF 1224 disables 5000 limit but keeps lock escalation due to memory pressure. Using ALTER TABLE to disable/enable lock escalation (SQL2008) Allows lock escalation at partition level

Lock Escalation Detection and Troubleshooting Tech Ed North America 2010 8/23/2018 1:32 AM Lock Escalation Detection and Troubleshooting Sunil Agarwal Senior Program Manager Microsoft DEMO © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Silent Blocker: Page Latches What is a Pagelatch? Schema and access patterns leading to latch contention Clustering index has a increasing primary key with high rate of inserts Relatively small tables with a lot of read/write/delete Indexes with low cardinality in the key with high rate of inserts Allocation Structures (e.g. SGAM) Observed with 16+ concurrent threads Page Header R1 Free Offset R2 R3

Silent Blocker: Page Latches What can you do? Cluster on some other column Partition the table on some other attribute (computed column (hash)) Add another major key column Change the application

Page Latch Contention and Troubleshooting Tech Ed North America 2010 8/23/2018 1:32 AM Page Latch Contention and Troubleshooting Sunil Agarwal Senior Program Manager Microsoft DEMO © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Deadlock Example: User 1 holds X lock on page P1 User 1 requests to acquire SH lock on P2 It waits for User 2 User 2 requests to acquire SH lock on P1 It waits for User 1 Leads to an indefinite wait

Deadlock: Detection Background Thread (Lock Monitor) Runs every 5 seconds (adjusted dynamically) When deadlock detected, a victim is chosen based on Transaction that has done minimum amount of work Deadlock priority. Victim transaction is rolled back and an error 1205 is generated. Deadlock Troubleshooting Use SQL profiler User TF-1204 (SQL2000) TF-1222 (SQL2005)

Deadlock Detection and Troubleshooting Tech Ed North America 2010 8/23/2018 1:32 AM Deadlock Detection and Troubleshooting Sunil Agarwal Senior Program Manager Microsoft DEMO © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Deadlock: Avoidance Access objects/rows in same order Use lower isolation level Use read-committed-snapshot or snapshot isolation Use shorter duration transactions Watch out for lock escalation

Guidelines: Concurrent Application Choose lowest isolation needed for consistency Use shorter transaction when possible Avoid using larger row sets Break the statement into smaller rowsets Minimize large scans Enable index usage when possible When possible, design to spread DML across multiple pages

Summary Balance consistency vs. concurrency Factors that impact concurrency Troubleshooting Blocking Best practices for developing concurrent applications

Required Slide Track PMs will supply the content for this slide, which will be inserted during the final scrub. Tech Ed North America 2010 8/23/2018 1:32 AM DAT Track Scratch 2 Win Find the DAT Track Surface Table in the Yellow Section of the TLC Try your luck to win a Zune HD Simply scratch the game pieces on the DAT Track Surface Table and Match 3 Zune HDs to win © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Resources Learning Required Slide www.microsoft.com/teched Tech Ed North America 2010 8/23/2018 1:32 AM Required Slide Resources Learning Sessions On-Demand & Community Microsoft Certification & Training Resources www.microsoft.com/teched www.microsoft.com/learning Resources for IT Professionals Resources for Developers http://microsoft.com/technet http://microsoft.com/msdn © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Complete an evaluation on CommNet and enter to win! Tech Ed North America 2010 8/23/2018 1:32 AM Required Slide Complete an evaluation on CommNet and enter to win! © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Sign up for Tech·Ed 2011 and save $500 starting June 8 – June 31st http://northamerica.msteched.com/registration   You can also register at the North America 2011 kiosk located at registration Join us in Atlanta next year

Tech Ed North America 2010 8/23/2018 1:32 AM © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION. © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Required Slide Tech Ed North America 2010 8/23/2018 1:32 AM © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.