Monitoring Data Changes with Change Data Capture

Slides:



Advertisements
Similar presentations
By: Jose Chinchilla July 31, Jose Chinchilla MCITP: SQL Server 2008, Database Administrator MCTS: SQL Server 2005/2008, Business Intelligence DBA.
Advertisements

Help! My table is getting too big! How to divide and conquer SQL Relay 2014.
Change Data Capture & Change Tracking Deep Dive
5 Common SQL Server Performance Issues Jason Hall-SQL Sentry, Dir of Client Services Blog-jasonhall.blogs.sqlsentry.net.
10 Things Not To Do With SQL SQLBits 7. Some things you shouldn’t do.
ARIE D. JONES (AJ) PRINCIPAL TECHNOLOGY MANAGER SQL Server for the Oracle DBA Sept 16 th 2009.
Introduction and simple using of Oracle Logistics Information System Yaxian Yao
Database Design for DNN Developers Sebastian Leupold.
Chapters 17 & 18 Physical Database Design Methodology.
SQL Server 2008 for Developers John
Windows Azure Tour Benjamin Day Benjamin Day Consulting, Inc.
© 2011 PLANET TECHNOLOGIES, INC. Create a FREE Weather RSS Web Part Patrick Curran, MCT AUGUST 12, 2011.
Agenda for Today Chapter 5 –Skip Lesson 2 Review questions Midterm Chapter 6 Review questions.
Informix IDS Administration with the New Server Studio 4.0 By Lester Knutsen My experience with the beta of Server Studio and the new Informix database.
Learningcomputer.com SQL Server 2008 – Administration, Maintenance and Job Automation.
Understanding SQL Server 2008 Change Data Capture Bret Stateham Training Manager Vortex Learning Solutions blogs.netconnex.com.
CHANGE DATA CAPTURE: A BRIEF OVERVIEW PRESENTED BY TIM WEIGEL
SQL SERVER AUDITING. Jean Joseph DBA/Consultant Contact Info: Blog:
Testing With Your Data, Your Way! Distributed Replay 1 SQLSat 470 Washington DC December 5, 2015.
October 15-18, 2013 Charlotte, NC Accelerating Database Performance Using Compression Joseph D’Antoni, Solutions Architect Anexinet.
Putting Your Head in the Cloud Working with SQL Azure David Postlethwaite 19/09/2015David Postlethwaite.
You Inherited a Database Now What? What you should immediately check and start monitoring for. Tim Radney, Senior DBA for a top 40 US Bank President of.
Transactional Replication it’s not scary Evgeny Khabarov.
WHEN DATABASE CORRUPTION STRIKES Presented by Steve Stedman Founder/Owner of Stedman Solution, LLC.
Session Name Pelin ATICI SQL Premier Field Engineer.
Name Developing your own Query Magic in SharePoint Search Virgil Carroll principal architect, high monkey.
11 Copyright © 2009, Oracle. All rights reserved. Enhancing ETL Performance.
10 Copyright © 2007, Oracle. All rights reserved. Managing Undo Data.
MANAGEMENT DATA WAREHOUSE AND DATA COLLECTOR Ian Lanham.
Use Cases for In-Memory OLTP Warner Chaves SQL MCM / MVP SQLTurbo.com Pythian.com.
SQL Database Management
With Temporal Tables and More
NO SQL for SQL DBA Dilip Nayak & Dan Hess.
Chris Index Feng Shui Chris
SQL Server Security & Intrusion Prevention
You Inherited a Database Now What?
Better Data Visualization with Reporting Services 2008 R2
Data Virtualization Demoette… ADO.NET Client
Antonio Abalos Castillo
Transactional replication
Where I am at: Swagatika Sarangi MDM Lead PASS Summit SQL Saturdays
Download Microsoft Exam Dumps - Valid Microsoft Question Answers - Realexamdumps.com
DevOps Database Administration
SQL Server May Let You Do It, But it Doesn’t Mean You Should
Purpose, Pitfalls and Performance Implications
Troubleshooting Service Broker
Introducing the SQL Server 2016 Query Store
Principles of report writing
DevOps Database Administration
5 WAYS TO BYPASS *OR ENSURE* SQL SERVER SECURITY MATT MARTIN
Making PowerShell Useful
Purpose, Pitfalls and Performance Implications
SQL Azure Database – No CDC, No Problem!
Introducing the SQL Server 2016 Query Store
Welcome to SQL Saturday Denmark
SQL SERVER 2014 Change Data Capture Dave Bland
Statistics: What are they and How do I use them
Steve Hood SimpleSQLServer.com
Turbo-Charged Transaction Logs
Enterprise Auditing with SQL Server Audit
SQL Server Agent The Life Preserver for the Drowning DBA Lance Tidwell.
Cloud Data Replication with SQL Data Sync
PowerShell & PowerBi Reducing DBAs Context Switching
PowerShell & PowerBi Reducing DBAs Context Switching
You Inherited a Database Now What?
Query Processing.
Why should I care about SQL, if I have ORM?
Using wait stats to determine why my server is slow
T-SQL Tools: Simplicity for Synchronizing Changes Martin Perez.
Presentation transcript:

Monitoring Data Changes with Change Data Capture Arie D. Jones (AJ) Principal Technology Manager Perpetual Technologies, Inc Blog : http://www.programmersedge.com Company Site: http://www.pti.net Email: arie.jones@pti.net Twitter: programmersedge #45 Louisville

Arie Jones (AJ) 20 + years application development experience 10 + years database experience Bunch of Alphabet Soup behind name The blog, the webcasts, the events….. Prolific writer SQL Functions Learn SQL in 24 Hours Learn SQL in 1Hour a Day Live Lessons: SQL

Agenda How does Change Data Capture work How to implement How to get to the data Sneaky Ninja DBA Tips

? How it Works So how does this mysterious Change Data Capture work? Let‘s take a look at how the magic happens….. That big question mark is editable – use whatever character you want!

Why use this? Gives you consistency Reduces programmatic overhead Reduces computational overhead

How it all works! Database Source Tables Log File Change Tables Capture Process User Queries

? How to Implement That’s awesome AJ but how to you get the thing working?? Let’s find out! That big question mark is editable – use whatever character you want!

Your Pre-Flight Checklist SQL Agent is on and set to Auto-Start You or someone you know has SysAdmin privileges CDC user does not exist in database A CDC schema does not exist in database You have a good cover story to explain how difficult the following process is to your manager/boss so as to strengthen your argument for a raise

Step #1 Enable on the instance Use sp_cdc_enable_db_change_data_capture Use sp_cdc_enable_db You may double check in sys.databases This you must have SysAdmin privileges for

Step #2 Wipe sweaty brow Enable CDC per table Use sp_cdc_enable_table_change_data_capture Use sp_cdc_enable_table You can double check in sys.tables You will notice 2 jobs having been created 1 = Get Stuff 2 = Cleanup Stuff

Sp_cdc_enable_table_change_data_capture @source_schema @source_name @role_name @capture_instance @supports_net_changes @index_name @captured_column_list @filegroup_name

Demo Let’s look at this in action!

? How to Query the Data Now, how do we get to the actual data that we are saving up? That big question mark is editable – use whatever character you want!

Querying Data Super easy syntax TableName_CT Will normally need system functions to get LSN Sys.fn_cdc_map_time_to_lsn Then will use one of 2 CDC query TVF Cdc.fn_cdc_get_all_changes_<schema>_<table> Cdc.fn_cdc_get_net_changes_<schema>_<table>

Sneaky Ninja DBA TIP #1! ETL Processes!

Demo Straight to a demo!

Sneaky Ninja DBA TIP #2! data forensics

Who’s making changes? You’ll notice in the CDC tables that there is no username… 2 Things you need to think about How are the users accessing the system? How much flexibility do you have to change things?

Easy way! ID Customer User Updated 1 Jane Good DBA 2 Steve Evil Developer 3 Bob ID Customer 1 Jane 2 Steve 3 Bob Change Data Capture takes care of the rest!!

Sneaky Ninja DBA TIP #3! Performance tuning!

Let me explain the process Job Sys.sp_MScdc_capture_job No Parameters! That’s CRAZY! Sys.sp_cdc_scan Hey wait! Isn’t that used in transactional replication? Sys.sp_replcmds

Demo Let’s jump into some code!

So What’s a DBA to Do? @captured_column_list @supports_net_changes Limit # of columns to only those you truly need @supports_net_changes Only use if you need net changes Puts an additional nonclustered index on change table @filegroup_name If not specified then change table is placed in default filegroup

Performance Tips Storage Workload Watch your log space Watch you log I/O Make sure you know which file group you have things stored in Workload Reduce the number of columns to the minimum Modify default scan parameters on BOTH the capture and cleanup jobs!

Thank You ! Questions and Answers Evaluation Sheets! Be sure to check out my upcoming events! PTI Monthly Webcasts: http://events.pti.net

SQL Saturday #45 Louisville @ SQL Saturday #45 Louisville Monitoring Data Changes with Change Data Capture Arie Jones(AJ) http://www.programmersedge.com http://www.sqlsherpa.com Email: arie.jones@pti.net Twitter: programmersedge Company: http://www.pti.net