Purpose, Pitfalls and Performance Implications

Slides:



Advertisements
Similar presentations
Yukon – What is New Rajesh Gala. Yukon – What is new.NET Framework Programming Data Types Exception Handling Batches Databases Database Engine Administration.
Advertisements

Copyright © SoftTree Technologies, Inc. DB Tuning Expert.
Mecanismos de alta disponibilidad con Microsoft SQL Server 2008 Por: ISC Lenin López Fernández de Lara.
SQL Server Replication
Observation Pattern Theory Hypothesis What will happen? How can we make it happen? Predictive Analytics Prescriptive Analytics What happened? Why.
Fundamentals, Design, and Implementation, 9/e Chapter 11 Managing Databases with SQL Server 2000.
Distributed Databases
National Manager Database Services
1 Chapter Overview Transferring and Transforming Data Introducing Microsoft Data Transformation Services (DTS) Transferring and Transforming Data with.
Phil Brewster  One of the first steps – identify the proper data types  Decide how data (in columns) should be stored and used.
Today’s Agenda Chapter 12 Admin Tasks Chapter 13 Automating Admin Tasks.
Chapter 10 : Designing a SQL Server 2005 Solution for High Availability MCITP Administrator: Microsoft SQL Server 2005 Database Server Infrastructure Design.
CHAPTER 9 DATABASE MANAGEMENT © Prepared By: Razif Razali.
How a little code can help with support.. Chris Barba – Developer at Cimarex Energy Blog:
Chapter Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.
Sofia, Bulgaria | 9-10 October SQL Server 2005 High Availability for developers Vladimir Tchalkov Crossroad Ltd. Vladimir Tchalkov Crossroad Ltd.
Maintaining a Mirrored Database Tips and Tricks by Paul G. Hiles.
By Lecturer / Aisha Dawood 1.  You can control the number of dispatcher processes in the instance. Unlike the number of shared servers, the number of.
Module 11: Programming Across Multiple Servers. Overview Introducing Distributed Queries Setting Up a Linked Server Environment Working with Linked Servers.
Process Architecture Process Architecture - A portion of a program that can run independently of and concurrently with other portions of the program. Some.
1 Chapter Overview Planning to Install SQL Server 2000 Deciding SQL Server 2000 Setup Configuration Options Running the SQL Server 2000 Setup Program Using.
SQL/Lesson 7/Slide 1 of 32 Implementing Indexes Objectives In this lesson, you will learn to: * Create a clustered index * Create a nonclustered index.
Alwayson Availability Groups
Infrastructure for Data Warehouses. Basics Of Data Access Data Store Machine Memory Buffer Memory Cache Data Store Buffer Bus Structure.
Course Topics Administering SQL Server 2012 Jump Start 01 | Install and Configure SQL Server04 | Manage Data 02 | Maintain Instances and Databases05 |
Oracle9i Performance Tuning Chapter 11 Advanced Tuning Topics.
Creating Simple and Parallel Data Loads With DTS.
Log Shipping, Mirroring, Replication and Clustering Which should I use? That depends on a few questions we must ask the user. We will go over these questions.
 What is DB Testing ?  Testing at the Data Access Layer  Need for Testing DB Objects  Common Problems that affect the Application  Should Testers.
SQL Server 2016 – New Features Tilahun Endihnew March 12, 2016.
All the things you need to know before setting up AlwaysOn Michael Steineke SQL & BI Solution Lead Enterprise Architect Concurrency, Inc.
FUN WITH AVAILABILITY GROUPS Christopher Wolff SQL Server Database Engineer, Xero.
1 Copyright © 2005, Oracle. All rights reserved. Oracle Database Administration: Overview.
Data Integrity & Indexes / Session 1/ 1 of 37 Session 1 Module 1: Introduction to Data Integrity Module 2: Introduction to Indexes.
Customer pulse Why Stretch? How Stretch works? Core Stretch scenarios Demo QA.
SQL IMPLEMENTATION & ADMINISTRATION Indexing & Views.
SQL Server DBA Online TrainingSQL Server DBA Online Training.
Partitioning & Creating Hardware Tablespaces for Performance
With Temporal Tables and More
Welcome POS Synchronize Concept 08 Sept 2015.
Smarter Technology for Better Business
DBMS & TPS Barbara Russell MBA 624.
Katowice,
MAKE YOUR QUERIES FASTER
Glasgow, SQL Server Meetup
Disaster Recovery Where to Begin
Lead SQL BankofAmerica Blog: SQLHarry.com
Physical Changes That Don’t Change the Logical Design
Always On Multi-Site Patterns
SQL Server Monitoring Overview
Isolation Levels Understanding Transaction Temper Tantrums
Contained DB? Did it do something wrong?
Dumps
Azure Automation and Logic Apps:
Agenda Database Development – Best Practices Why Performance Matters ?
Purpose, Pitfalls and Performance Implications
12/9/2018 Desktop Virtualization Corey Hynes Kyle Rosenthal President Technical Lead HynesITe Inc Spider Consulting @windowspcguy.
Cloud Data Replication with SQL Data Sync
EJ Grom, The Group, LLC Trang Le, EPA
The PROCESS of Queries John Deardurff Website: ThatAwesomeTrainer.com
High Availability/Disaster Recovery Solution
Chapter 11 Managing Databases with SQL Server 2000
Performance And Scalability In Oracle9i And SQL Server 2000
Understanding Core Database Concepts
Isolation Levels Understanding Transaction Temper Tantrums
Advanced Database Topics
Vendor Software Lessons From Consulting Vendor Software.
SQL Server 2016 High Performance Database Offer.
Implementing ETL solution for Incremental Data Load in Microsoft SQL Server Ganesh Lohani SR. Data Analyst Lockheed Martin
Presentation transcript:

Purpose, Pitfalls and Performance Implications Linked Servers Purpose, Pitfalls and Performance Implications http://blog.moserit.com/letting-all-the-air-out-of-linked-servers Linked Servers is an important tool in the DBA tool belt that, like most tools, can be super helpful or cause pain and anguish depending on how they are used. We are going to define what Linked Servers are, how they can be used, some tips on how best to use them, important performance implications, and some real-world query tuning examples.

About Ben Davis Senior Consultant specializing in SQL Server 10 years working with SQL Server Background in infrastructure, virtualization, storage, industrial automation Experience primarily in manufacturing and financial services verticals Resides in Lafayette, IN with wife and three boys LinkedIn - www.linkedin.com/in/bendavisitpro Twitter @BenjaminDavis22 Hobbies – home mechanic, track days, ketogenic (low-carb) lifestyle

What is a linked server? A remote data source that SQL Server can access directly in queries Can be another SQL instance or another OLE DB compliant product such as Oracle, IBM DB2, or Excel SELECT * FROM [SQL2].[DB].[dbo].[table] SQL Server acts as a client to another data source

Why would I use a linked server? Joining local & remote data Not feasible to bring data into local instance Managed/owned by someone else Primary use is by other applications, your use is minor/occasional Change rate is too frequent to consider for ETL Convenience No need to handle joining in the app Skillset present to write the join in T-SQL instead of thru app Network not accessible by app server Inability of SQL client application to connect to another data source type

How to setup 1. Add SQL Server linked server. 2. Add Azure linked server. 3. Add Oracle provider. C:\Users\benjamin.davis2\Downloads\ODAC122010Xcopy_x64\install.bat all c:\oracle odac

Best Practices Bring over as little data as possible If repeated access to the same data, save data in a local temp table for quick access Use should be uncommon, not for regular transactional use. If regular access needed, consider co-locating databases Consider multiple app connections and joining data in the app

MS DTC Microsoft Distributed Transaction Coordinator is required for transactions across instances Need to enable a few things in the Component Services applet Network DTC Access Allow Remote Clients Allow Inbound/Outbound Mutual Authentication or No Authentication Required

MS DTC Configuration

XACT_ABORT Will rollback entire distributed transaction if a run-time error occurs (like a PK constraint failure) when ON If set to OFF (default setting), the individual statement fails but the remainder of statements in the transaction are committed Must be ON for transactions against OLE DB providers, including SQL Server

Support for Mirroring, AGs Until SQL 2016, distributed transactions were not supported for database mirroring or Availability Groups. 2016 allowed this, but only if databases were on different servers 2017 has full support for distributed transactions on Availability Groups no matter the scenario https://docs.microsoft.com/en-us/sql/database-engine/availability-groups/windows/configure-availability-group-for-distributed-transactions

Distributed Transaction Support on SQL Server 2016 DB1 primary DB1 secondary DB2 primary DB2 secondary WSFC Instance 1 WSFC Instance 2 WSFC Instance 3 WSFC Instance 4 SUPPORTED DB1 primary DB1 secondary DB2 primary DB2 secondary WSFC Instance 1 WSFC Instance 2 WSFC Instance 3 NOT SUPPORTED

Tuning example SQL job with linked server references was taking 9.5 hours every day to run. The code had linked server calls and the called code had linked server calls back. Left graph is the linked server source instance wait. Right is the target instance wait. Wait type on source instance was a combination of CPU and OLEDB. Wait type on the target instance was all OLEDB.

Diagram of query EXEC spLinked2017 SQL2017 SQL2016 EXEC spLinked2016 SELECT * FROM Customers…

Tuning example Clustered index scan operation on local table sub-select taking 97% of plan time No index on datetime column in WHERE clause – was doing Clustered Index Scan Added non-clustered index on datetime column Decreased job time from 9.5 to 1.5 hours

Tuning example Next day overall instance wait time after this one change But you think I was satisfied? Heck no! This was too much fun!

Tuning example Step 2 – most tables in stored procedure were accessing remote tables. How about creating a remote version of the stored procedure to call from local SQL Agent? That way, most of the work is done on the instance with the majority of the data on it

Tuning example Step 3 – grab what little remote data there is from the new remote stored procedure into a temp table as it is use repeatedly Step 4 – Instead of a “NOT IN (SELECT column)”, often a LEFT JOIN between tables with “WHERE column IS NULL” is faster.

Tuning result Implementing Steps 2-4 further decreased run time to 16 minutes

http://blog.moserit.com/letting-all-the-air-out-of-linked-servers Ben Davis Senior Consultant BENJAMIN.DAVIS2@MOSERIT.COM 765.412.6838 | mobile 317.596.8022 | office