When Good Design Goes Bad Bob Duffy. SQLSaturday #467 Sponsors.

Slides:



Advertisements
Similar presentations
Tuning: overview Rewrite SQL (Leccotech)Leccotech Create Index Redefine Main memory structures (SGA in Oracle) Change the Block Size Materialized Views,
Advertisements

Adam Jorgensen Pragmatic Works Performance Optimization in SQL Server Analysis Services 2008.
The HV-tree: a Memory Hierarchy Aware Version Index Rui Zhang University of Melbourne Martin Stradling University of Melbourne.
Big Data Working with Terabytes in SQL Server Andrew Novick
Data warehousing with MySQL MySQLMS-SQLOracleDB2 MySQL Flat Files.
Dos and don’ts of Columnstore indexes The basis of xVelocity in-memory technology What’s it all about The compression methods (RLE / Dictionary encoding)
10 Things Not To Do With SQL SQLBits 7. Some things you shouldn’t do.
Chapter Physical Database Design Methodology Software & Hardware Mapping Logical Design to DBMS Physical Implementation Security Implementation Monitoring.
1 External Sorting for Query Processing Yanlei Diao UMass Amherst Feb 27, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
Chapter 9 Overview  Reasons to monitor SQL Server  Performance Monitoring and Tuning  Tools for Monitoring SQL Server  Common Monitoring and Tuning.
Fast Track, Microsoft SQL Server 2008 Parallel Data Warehouse and Traditional Data Warehouse Design BI Best Practices and Tuning for Scaling SQL Server.
Russ Houberg Senior Technical Architect, MCM KnowledgeLake, Inc.
Performance Tuning SSIS. HR Departments are no fun. Don’t mention the stalking incident with Clay Aiken What happened in Vegas My prom date with a puppet.
2 Overview of SSIS performance Troubleshooting methods Performance tips.
Oracle Challenges Parallelism Limitations Parallelism is the ability for a single query to be run across multiple processors or servers. Large queries.
Physical Database Design & Performance. Optimizing for Query Performance For DBs with high retrieval traffic as compared to maintenance traffic, optimizing.
SESSION CODE: BIE07-INT Eric Kraemer Senior Program Manager Microsoft Corporation.
Applications hitting a wall today with SQL Server Locking/Latching Scale-up Throughput or latency SLA Applications which do not use SQL Server.
Srik Raghavan Principal Lead Program Manager Kevin Cox Principal Program Manager SESSION CODE: DAT206.
How to Build Scalable & Secure Database Applications Noel Jerke & Erin Welker Scalability Experts.
08-Nov Database TEG workshop, Nov 2011 ATLAS Oracle database applications and plans for use of the Oracle 11g enhancements Gancho Dimitrov.
Physical Database Design Purpose- translate the logical description of data into the technical specifications for storing and retrieving data Goal - create.
Introduction.  Administration  Simple DBMS  CMPT 454 Topics John Edgar2.
Copyright © 2006, GemStone Systems Inc. All Rights Reserved. Increasing computation throughput with Grid Data Caching Jags Ramnarayan Chief Architect GemStone.
Connect with life Nauzad Kapadia Quartz Systems
Infrastructure for Data Warehouses. Basics Of Data Access Data Store Machine Memory Buffer Memory Cache Data Store Buffer Bus Structure.
Session 1 Module 1: Introduction to Data Integrity
Last Updated : 27 th April 2004 Center of Excellence Data Warehousing Group Teradata Performance Optimization.
Data Management Conference Performance & Scalability Simon Sabin London September 29th.
SSIS – Deep Dive Praveen Srivatsa Director, Asthrasoft Consulting Microsoft Regional Director | MVP.
DMBS Internals I February 24 th, What Should a DBMS Do? Store large amounts of data Process queries efficiently Allow multiple users to access the.
Technology Drill Down: Windows Azure Platform Eric Nelson | ISV Application Architect | Microsoft UK |
CS4432: Database Systems II
October 15-18, 2013 Charlotte, NC Accelerating Database Performance Using Compression Joseph D’Antoni, Solutions Architect Anexinet.
Honest Bob’s Cube Processing Bob Duffy Database Architect Prodata SQL Centre of Excellence 18 th July, 2014.
How to kill SQL Server Performance Håkan Winther.
Load Testing Analysis Services 30 th march 2012 Bob Duffy Database Architect Prodata SQL Centre of Excellence.
APRIL 13 th Introduction About me Duško Mirković 7 years of experience.
Universiteit Utrecht MONET CD Session 9 | Monday 6 June 2005 Lee Provoost.
Configuring SQL Server for a successful SharePoint Server Deployment Haaron Gonzalez Solution Architect & Consultant Microsoft MVP SharePoint Server
Honest Bob’s Cube Processing Bob Duffy Database Architect.
Load Testing with SQL Server Tools Neil Hambly SQL Server Practice Lead Northdoor PLC.
Session Name Pelin ATICI SQL Premier Field Engineer.
Indexing strategies and good physical designs for performance tuning Kenneth Ureña /SpanishPASSVC.
SQL 2012 – Always On Deep Dive Bob Duffy Database Architect Prodata SQL Centre of Excellence 11 th April 2013.
Data Integrity & Indexes / Session 1/ 1 of 37 Session 1 Module 1: Introduction to Data Integrity Module 2: Introduction to Indexes.
Migrating to Azure and the Cloud Bob Duffy Database Architect Prodata SQL Centre of Excellence 28th Sept, 2013.
When Good Design Goes Bad Bob Duffy Database Architect Prodata SQL Centre of Excellence March 2015.
Data Warehouse ETL By Garrett EDmondson Thanks to our Gold Sponsors:
Chris Index Feng Shui Chris
CygNet Database Service Diagnostics and Performance Tuning
Temporal Databases Microsoft SQL Server 2016
CS 540 Database Management Systems
Flash Storage 101 Revolutionizing Databases
Installation and database instance essentials
Software Architecture in Practice
Blazing-Fast Performance:
Marcos Freccia Stop everything! Top T-SQL tricks to a developer
What Azure have to offer for your data
April 30th – Scheduling / parallel
SQL 2014 In-Memory OLTP What, Why, and How
20 Questions with Azure SQL Data Warehouse
Indexes: The Basics Kathi Kellenberger.
Azure SQL DWH: Optimization
Indexing For Optimal Performance
Designing Complex Tabular Models
Using Columnstore indexes in Azure DevOps Services. Lessons learned
Using Columnstore indexes in Azure DevOps Services. Lessons learned
Moving your on-prem data warehouse to cloud. What are your options?
The Ins and Outs of Indexes
Presentation transcript:

When Good Design Goes Bad Bob Duffy

SQLSaturday #467 Sponsors

SQLSaturday #467 Admin  Raffle prizes from Sponsors  Will be drawn at 17:00, you need to be here in order to win if your name is drawn.  Lunch will be served in the Exhibitor Area at 12:00 with sponsor sessions taking place in session rooms.  If you need to leave early can you let registration know  We need to know who is still here in the event of a fire evacuation etc. Enjoy the sessions and have a great time

Bob Duffy 20 years in database sector, 250+ projects 20 years in database sector, 250+ projects Senior Consultant with Microsoft Senior Consultant with Microsoft One of about 25 MCA for SQL Server globally (aka SQL Ranger) One of about 25 MCA for SQL Server globally (aka SQL Ranger) SQL MCM on SQL 2005 and 2008 SQL MCM on SQL 2005 and 2008 SQL Server MVP SQL Server MVP SSAS Maestro SSAS Maestro Database Architect at Prodata SQL Centre of Excellence Database Architect at Prodata SQL Centre of Excellence @bob_duffy

What We Will Cover Stored Procedures Clustered Tables Identity and Primary Keys IndexesFragmentation Naming Conventions Partitioning ORMs and nvarchar(max)

1. Stored Procedures Why use Stored Procedures ?

The Chunky v Chatty Debate Two Types of “Chunkiness” Data Transferred per Call Number of Statements per Batch or Business Transaction Network latency Important here

The Dreaded Search Screen

Stored Procedure Weigh In PerformanceSecurity Plan Cache MaintainabilityChunky Dynamic Design Patterns Slow Interpreted TSQL Application Agility Developer Agility The ORM Debate Chatty

2. Clustered vs Heap Best Practise: Cluster ALL Tables ? Ever Increasing, Narrow, Unique, Static Always use an Identity Column

The Good Stuff PrimaryKey Record Selection SELECT * FROM ORDERS WHERE ORDER_ID=1 Range Scans SELECT * FROM ORDER_LINES WHERE ORDER_ID=1 SELECT * FROM FACT WHERE DATE BETWEEN X AND Y Efficient Updates/Deletes

Insert Scalability Harder to Scale, especially for some key choices

Large Table Scan Workloads Non sequential Clustering Keys Cause Fragmentation Why is Fragmentation the Achilles Heel of table Scans Prevents sequential disk access More Pages => More IO Kills Read Ahead and disk performance

Heavy NCI Requirement Best Practise “Clustered Index are Better for Seeks” Well it depends on if the seek is on a NCI or not!

Clustered Index v Heap Ascending Keys Range Scans Lots of Deletes/Updates Tables with Heavy Primary Seek Most Logging Tables Insert and Scan heavy Tables OLTP Transaction Tables (banking) Bulk Loading

3 Always use Identity for Primary/CX Key Best Practise Always Use an Identity Column as Primary Key Extension: Always add a new Surrogate Key This may shoot you in the foot on large Fact Tables

The Distributed Database Choice of Identity will cause a lot of pain! How common is this Issue? Very Frequent with replication and new MPP Architectures

Distributed Write Cache ? Identity creates a bottleneck on the DB Serializes new records What if database offline ?

The Over Zealous Surrogate Key This may go bad if you are not a “single hop” data source

4. We Don’t Need no Indexes? Best Practise. Add Indexes.. To Reduce IO on important Queries Seek rather than scan. SELECT * WHERE CustomerID=2 Narrower Scan. SELECT SUM(Qty) DateKeyCustomerRegionKey Sales € Qty Cost Jan Feb Mar April May June July Aug

When Indexes go bad OLTP Small Tables Larger Results – See “The Tipping Point” by Kimberly Tripp When upsert is more important then select When every column Indexed High Throughput Queueing Design Patterns DWH Bad “Tipping Points” Staging Tables Tables that we scan When avoiding bad statistics is very hard Data Analytics, Data Science and Big Data Queries Where we need guaranteed query performance for varied workloads.

Guaranteed Performance !!?! We have a 1TB Table. Query SLA is 5 mins… Add indexes?

5 Fragmentation Best Practise – Defragment the hell out of your database Maintains optimal Scan performance

Why ignore Fragmentation Our workload is mainly seeks Helps with Insert Scalability Maintenance may load server Optimal read ahead may not be important More Memory will reduce reliance on contiguous disk blocks Most SANs only do random IO anyway

Naming Conventions Best Practice – use one! Goes Bad When prefix is meta data (object type, data type, size)

Naming – Common Sense Project with following prefix standards on SSIS DATA Source Transform Type (LOAD, TRANSFORM, EXTRACT) Package Control Flow Shape

Easier Maintenance/Archiving Storage Tiering Faster Query Performance Improved Parallelism Better Plans Partition Elimination Improve Data Load Improve Data Load The Holy Sliding Window Partitioning Best Practise – Partition when table it too big or too slow

Partitioning Introduces “forced” parallelism Often the query processor will do a better job Scan speed can be slower Parallelism may be worse

Many common queries may be slower Especially if all queries do not use the partition key Use of “ordered” NCI” is a car crash Index Seeks

8 ORMs Best Practise ? Hotly debated Good For CRUD Cache Management (Some of them) Portable Developer Agility Code First, Database Second Integrated Debugging Domain Business Model Key Management

Query Plan Nightmares Source:

When ORMs go Bad Can write truly horrible TSQL and Plans Higher overhead than ADO.NET Parameterisation nvarchar (4000)! The Disaster Scenario Lazy/Eager Loading Can be used as an excuse of lack of database expertise Hard to Index for (lots of Select *)

Everything has good and bad Aspects It Depends ;-)

Thank You