Presentation is loading. Please wait.

Presentation is loading. Please wait.

TechEd 2013 1/14/2019 1:34 AM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.

Similar presentations


Presentation on theme: "TechEd 2013 1/14/2019 1:34 AM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks."— Presentation transcript:

1 TechEd 2013 1/14/2019 1:34 AM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

2 1/14/2019 1:34 AM DBI-B330 Cloud Optimizing T-SQL: What You Need to Know If You Use SQL Database or Microsoft SQL Server 2012 Jan Engelsberg Program Manager © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

3 Agenda What is different in SQL Database & Why?
Could optimizing your design Connection Reliability Reducing round-trips Caching

4 Three different ways to run SQL
TechEd 2013 1/14/2019 1:34 AM Three different ways to run SQL High “Friction”/Control Resources Dedicated Shared Low SQL Server Raw iron Scale-up Full h/w control Roll-your-own HA/DR/scale 100% of API, Virtualized Roll-your-own HA/DR/scale SQL Server in IaaS Virtualized Machine Auto HA, Fault-Tolerance Friction-free scale Self-provisioning, scale Virtualized Database SQL Database - PaaS © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

5 What is different in SQL Database & Why?
TechEd 2013 1/14/2019 1:34 AM What is different in SQL Database & Why? Traditional vs. Cloud Datacenter layout SQL Instance vs. virtualized Database Machine 1 Application Server Machine 4 SQL Server Instance Machine 1 Application Server $$$$$ $ Machine 1 SQL Server Instance $ Machine 1 SQL Server Instance Machine 1 SQL Server Instance DB DB DB DB DB DB DB DB DB Machine 4 SQL Server Instance Machine 2 Application Server $ $ Machine 2 $ $$$$$ Machine 2 Machine 2 SQL Server Instance SQL Server Instance SQL Server Instance DB DB DB DB DB DB DB Machine 2 SQL Server Instance UserDB Master DB DB $$$$$ Machine 4 SQL Server Instance Machine 3 Application Server $ Machine 3 $ Machine 2 Machine 2 SQL Server Instance SQL Server Instance SQL Server Instance DB DB DB DB DB DB DB DB DB © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

6 Cloud optimizing your database design
Master MSDB Temp Master MSDB User DB User DB Instance Collation Logins Credentials Linked Server Defs. CLR Agent Replication DB Mail User DB TempDB Collation Other Apps Other DBs TempDB User DB

7 Cloud optimizing your database design
Feature = All syntax or semantic changes to the surface area Database Feature Very few features are both Example: CREATE DATABASE Only grand fathering here No new features that have this characteristic will be added Host Feature Contained within a database Examples: Table Trigger Database Firewall rules Not contained within a database Examples: High Availability DR Database Host

8 Best Practices Instrument, instrument, instrument
DMVs, SET STATISTICS …, XEvents, …  Next slide Automate, automate, automate Optimize your database design & queries Make your app resilient to failures  More details in a bit Minimize roundtrips

9 Instrumenting your app
TechEd 2013 1/14/2019 1:34 AM Instrumenting your app Snapshotting DMVs Collecting XEvents DB DB DB DB DW DB DB DB DB DB © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

10 Connection Reliability
Issue types Exception  Message from server/app indicating failure Timeout (or user impatience)  No message from server/app within desired response time Unreliable User Client app Web Server DB Server Not durable Durable

11 Let’s look at what can happen
X Web Server DB Server ? X Request is executed on the Server  Retry for reads is safe  Retry for writes is NOT safe Request has not yet reached the server  Retry for reads and writes is safe The request has reached the server  Retry for reads is safe  Retry for writes is NOT safe

12 Safe retry-protocol for writes
Client Assign a unique ID (GUID) to request Send request to server Send transaction received notification Server If request ID already exists return error message Begin transaction Save request ID Execute request Commit transaction Return result Delete request ID Retention clean-up

13 Retry considerations Read Write Just re-execute
TechEd 2013 1/14/2019 1:34 AM Retry considerations Read Write Just re-execute Requires tracking of transaction ID Requires outer transaction Low cost operation High cost operation A general system wide back-off strategy is typically a good idea Query dependent back-off strategy to avoid overloading the system © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

14 Reducing round-trips Get all @ once Batch updates
TechEd 2013 1/14/2019 1:34 AM Reducing round-trips Get once Issue one query that gets the data you need Consider using FOR XML for simpler consumption Batch updates Example - “Update the following 1000 entities” N updates  N round-trips vs. N updates  <N (1?) round-trips SELECT… SELECT… SELECT… SELECT… N  N One client server roundtrip per execution N  <N XML Delimited list Table Valued Parameter All executions in one batch © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

15 Reducing round-trips cont’d
Roundtrip per execution Delimited list XML Table Valued Parameter Fully streaming Easy to use Performance is good No SQL Injection Can be strongly typed No SQL Injection Nice option if your data is already XML! Great flexibility Strongly typed No SQL Injection Performance is great! Easy to use Allows for some level of streaming Poor performance Potential for SQL Injection attacks Requires SQLCLR Data is not strongly typed Cumbersome implementation Can be simplified by created one TVF per “list type” Not strongly typed by default Performance is ok but not the best Less cumbersome than the delimited list but still somewhat cumbersome Less flexible than XML Allows for streaming, but only to the server

16 Caching Cache aggressively Rowversion vs. Checksums
TechEd 2013 1/14/2019 1:34 AM Caching Cache aggressively This is based on a business requirement: “How fresh does the data I show you have to be?” Rowversion vs. Checksums Rowversion is automatic, Checksums need to be calculated manually Rowversion changes on any row update, Checksum can be calculated per column set Rowversion can be used as “high water mark” CHECKSUM vs. HASBYTES (CONCAT(…)) Querying efficiently Typically convert rowversion to BIGINT for simpler handling in the client tier Avoid creating indexes on these columns, will cause fragmentation for highly updated tables Include other predicates when possible © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

17 1/14/2019 1:34 AM Related content Breakout Exploring Microsoft SQL Server Data Tools in Visual Studio 2012 Microsoft SQL Server Database Development with SQL Server Data Tools for Visual Studio 2012 Query Performance Tuning Techniques For Windows Azure SQL Database Overview, Best Practices and Lessons Learned on Microsoft SQL Server in Windows Azure Virtual Machines Hands-on Labs Exploring New T-SQL Features in Microsoft SQL Server 2012 Find Me Later At… TLC Area after this session & tomorrow morning Ask The Experts tables © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

18 Download Data Explorer
Track Resources Download Data Explorer SQL Server Website Hands-On Labs @sqlserver Download Geoflow mva Microsoft Virtual Academy Get Certified! Windows Azure

19 Resources Learning TechNet msdn http://channel9.msdn.com/Events/TechEd
1/14/2019 1:34 AM Resources Learning Sessions on Demand Microsoft Certification & Training Resources TechNet msdn Resources for IT Professionals Resources for Developers © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

20 Complete an evaluation on CommNet and enter to win!
1/14/2019 1:34 AM Complete an evaluation on CommNet and enter to win! © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

21 1/14/2019 1:34 AM Required Slide *delete this box when your slide is finalized Your MS Tag will be inserted here during the final scrub. Evaluate this session Scan this QR code to evaluate this session and be automatically entered in a drawing to win a prize © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

22 1/14/2019 1:34 AM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows 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. © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.


Download ppt "TechEd 2013 1/14/2019 1:34 AM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks."

Similar presentations


Ads by Google