When Good Design Goes Bad Bob Duffy Database Architect Prodata SQL Centre of Excellence March 2015.

Slides:



Advertisements
Similar presentations
Big Data Working with Terabytes in SQL Server Andrew Novick
Advertisements

Data warehousing with MySQL MySQLMS-SQLOracleDB2 MySQL Flat Files.
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.
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.
BW Know-How Call : Performance Tuning dial-in phone numbers! U.S. Toll-free: (877) International: (612) Passcode: “BW”
Srik Raghavan Principal Lead Program Manager Kevin Cox Principal Program Manager SESSION CODE: DAT206.
SSIS – Deep Dive Praveen Srivatsa Director, Asthrasoft Consulting Microsoft Regional Director | MVP.
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.
Universiteit Utrecht MONET CD Session 9 | Monday 6 June 2005 Lee Provoost.
When Good Design Goes Bad Bob Duffy. SQLSaturday #467 Sponsors.
Honest Bob’s Cube Processing Bob Duffy Database Architect.
Carlos Bossy Quanta Intelligence SQL Server MCTS, MCITP BI CBIP, Data Mining Real-time Data Warehouse and Reporting Solutions.
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.
Use Cases for In-Memory OLTP Warner Chaves SQL MCM / MVP SQLTurbo.com Pythian.com.
Data Warehouse ETL By Garrett EDmondson Thanks to our Gold Sponsors:
SQL Storage Fundamentals for Azure IaaS
Chris Index Feng Shui Chris
Data Warehousing Best Practices
Indexing Goals: Store large files Support multiple search keys
Flash Storage 101 Revolutionizing Databases
Optimizing Reporting Services
Finding more space for your tight environment
Installation and database instance essentials
Chapter Overview Understanding the Database Architecture
Software Architecture in Practice
Presented by: Warren Sifre
Hustle and Bustle of SQL Pages
SQL Storage Fundamentals for Azure IaaS
Marcos Freccia Stop everything! Top T-SQL tricks to a developer
What Azure have to offer for your data
April 30th – Scheduling / parallel
Real world In-Memory OLTP
Azure SQL Data Warehouse Performance Tuning
SQL 2014 In-Memory OLTP What, Why, and How
Introduction to PIG, HIVE, HBASE & ZOOKEEPER
Designing Business Intelligence Solutions with Microsoft SQL Server
Physical Database Design
20 Questions with Azure SQL Data Warehouse
Stop Wasting Time & Resources: Performance Tune Your Jobs
Indexes: The Basics Kathi Kellenberger.
Steve Hood SimpleSQLServer.com
The Ins and Outs of Indexes
TEMPDB – INTERNALS AND USAGE
Azure SQL DWH: Optimization
In Memory OLTP Not Just for OLTP.
The PROCESS of Queries John Deardurff Website: ThatAwesomeTrainer.com
Save Time & Resources: Job Performance Tuning Strategies
Indexing For Optimal Performance
Designing Complex Tabular Models
CPS216: Advanced Database Systems
The Curious case of the foreign key
Are you following SQL Server Development Best Practices?
Top 5 TIPS TO KEEP Always on AGs humming and users happy
Hybrid Power BI With the on Premise Data Gateway
Sourav Mukherjee Are you following SQL Server Development Best Practices? March 30, 2019 Cincinnati.
Bob Duffy 27 years in database sector, 250+ projects
Using Columnstore indexes in Azure DevOps Services. Lessons learned
Bob Duffy 22 years in database sector, 250+ projects
Using Columnstore indexes in Azure DevOps Services. Lessons learned
CS222/CS122C: Principles of Data Management UCI, Fall 2018 Notes #03 Row/Column Stores, Heap Files, Buffer Manager, Catalogs Instructor: Chen Li.
Parallel DBMS DBMS Textbook Chapter 22
The Ins and Outs of Indexes
Dimension Load Patterns with Azure Data Factory Data Flows
Presentation transcript:

When Good Design Goes Bad Bob Duffy Database Architect Prodata SQL Centre of Excellence March 2015

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 PartitioningORM

1. Stored Procedures Why use Stored Procedures ?

The Dreaded Search Screen

The Chunky v Chatty Debate Two Types of “Chunkiness” Data Transferred per Call Number of Calls Network latency Important here

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

When do Clustered Tables go Bad ? 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 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 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

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

The Over Zealous Dimensional Modeller 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 Where we need guaranteed query performance for varied workloads.

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

5 Stop Worrying about Fragmentation Best Practise – Defragment the hell out of your database Why could this be bad ? Takes a long time and may interfere with query performance Why Could this be not worth the bother ? More Memory will reduce reliance on contiguous disk blocks Most SANs only do random IO anyway Its mainly important if our primary concerns are Scans

6 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

7 Partitioning Maintenance Operations Parallel Queries Best Practise – Partition when table it too big or too slow Ordered Queries Serial Queries Dynamic Parallel Queries

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

Query Plan Nightmares Source:

When ORMs go Bad Can write truly horrible TSQL and Plans Naïve context Parameterisation 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 ;-)