Marcos Freccia Stop everything! Top T-SQL tricks to a developer https://github.com/marcosfreccia/sql-saturday-689-prague.

Slides:



Advertisements
Similar presentations
How a little code can help with support.. Chris Barba – Developer at Cimarex Energy Blog:
Advertisements

Database Design for DNN Developers Sebastian Leupold.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Database Performance Tuning and Query Optimization.
DBSQL 14-1 Copyright © Genetic Computer School 2009 Chapter 14 Microsoft SQL Server.
Views In some cases, it is not desirable for all users to see the entire logical model (that is, all the actual relations stored in the database.) In some.
Data Driven Designs 99% of enterprise applications operate on database data or at least interface databases. Most common DBMS are Microsoft SQL Server,
T-SQL: Simple Changes That Go a Long Way DAVE ingeniousSQL.com linkedin.com/in/ingenioussql.
Indexes / Session 2/ 1 of 36 Session 2 Module 3: Types of Indexes Module 4: Maintaining Indexes.
Course FAQ’s I do not have any knowledge on SQL concepts or Database Testing. Will this course helps me to get through all the concepts? What kind of.
Indexes and Views Unit 7.
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.
Session 1 Module 1: Introduction to Data Integrity
Learningcomputer.com SQL Server 2008 –Views, Functions and Stored Procedures.
Database Performance Eric Grancher - Nilo Segura Oracle Support Team IT/DES.
Database Overview What is a database? What types of databases are there? How are databases more powerful than spreadsheets?
Doing fast! Optimizing Query performance with ColumnStore Indexes in SQL Server 2012 Margarita Naumova | SQL Master Academy.
Data Integrity & Indexes / Session 1/ 1 of 37 Session 1 Module 1: Introduction to Data Integrity Module 2: Introduction to Indexes.
Others Talk, We Listen. Managing Database Projects in Visual Studio 2013.
Understanding Core Database Concepts Lesson 1. Objectives.
SQL Server Statistics and its relationship with Query Optimizer
Chris Index Feng Shui Chris
Cleveland SQL Saturday Catch-All or Sometimes Queries
Antonio Abalos Castillo
UFC #1433 In-Memory tables 2014 vs 2016
T-SQL: Simple Changes That Go a Long Way
Efficiently Searching Schema in SQL Server
Parameter Sniffing in SQL Server Stored Procedures
SQL Server Monitoring Overview
Reading execution plans successfully
Database Management  .
Software Architecture in Practice
Database Performance Tuning and Query Optimization
Hustle and Bustle of SQL Pages
Reading Execution Plans Successfully
Blazing-Fast Performance:
SQL Server May Let You Do It, But it Doesn’t Mean You Should
Power BI Performance …Tips and Techniques.
Getting To Know Your Indexes
Agenda Database Development – Best Practices Why Performance Matters ?
Prove to your boss your database is sound - Unit Testing with tSQLt
Query Optimization Techniques
JULIE McLAIN-HARPER LINKEDIN: JM HARPER
Migrating your local database to Azure SQL DB
Statistics: What are they and How do I use them
Chapter 4 Indexes.
CH 4 Indexes.
Reading Execution Plans Successfully
Tracking Index Usage Like a Pro
TEMPDB – INTERNALS AND USAGE
Please thank our sponsors!
When I Use NOLOCK AND OTHER HINTS
Transact SQL Performance Tips
In Memory OLTP Not Just for OLTP.
The PROCESS of Queries John Deardurff Website: ThatAwesomeTrainer.com
Understanding Transaction Isolation Levels
CH 4 Indexes.
Stretch Database - Historical data storage in SQL Server 2016
Patrick Flynn | Link Group Australia
Summit Nashville /3/2019 1:48 AM
Chapter 11 Database Performance Tuning and Query Optimization
Score a (row) goal and beat a query optimizer
Execution plans Eugene
Indexes and more Table Creation
SQL Server Query Design and Optimization Recommendations
Query Optimization Techniques
Understanding Core Database Concepts
Reading execution plans successfully
T-SQL Basics: Coding for performance
Why should I care about SQL, if I have ORM?
Navigating SSMS Primer for Beginners
Presentation transcript:

Marcos Freccia Stop everything! Top T-SQL tricks to a developer https://github.com/marcosfreccia/sql-saturday-689-prague

Marcos Freccia SQL Server DBA at Zalando SE @sqlfreccia sqlfreccia@outlook.com http://marcosfreccia.wordpress.com Data Platform MVP MCSA DBA & DBA SQL Server 2016 – Charter MCSE Data Management and Analytics SQL Server 2016 – Charter SQL Server DBA for 8 years Originally from Brazil, now living in Berlin, Germany

Why this session? Most of the times we skip the basics We focus too much on hardware and forget software You don’t need to be a master to do that Why I think this session is important to you?

Session Aim Enable you to get better database performance, without much effort.

Agenda Using the right tools is important Foreign Keys and Indexes Why Stored Procedures are a good idea? Designing matters & Designing Good Indexes Temporary Tables or Table Variables Maintaining Indexes Speeding up data load Take advantage of SQL Server Integration Services – If we still have time

Using the right tools is important Management Studio is your friend Always install the latest updates! https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms SentryOne Plan Explorer is your best friend! Full version completely free: https://www.sentryone.com/plan-explorer Shows much more information regarding execution plans, hidden information, Top Operations and so on.. Statistics Parser Parses the Statistics IO and Statistics Time http://statisticsparser.com/ Really time saving! Thanks to Richie Rump (@Jorriss) SQL Query Stress Tool! Created by Adam Machanic to enable the user to test a query: http://sqlblog.com/blogs/adam_machanic/archive/2016/01/04/sqlquerystress-the-source-code.aspx Recently the source code was released by him and now on Github: https://github.com/ErikEJ/SqlQueryStress

Foreign Keys and Indexes Used to link two tables together A field or collection of fields in one table that refers to the Primary Key in the other table Used to speed up performance of queries Avoids reading/scanning unnecessary data

Demo

Foreign Keys and Indexes Always create Foreign Keys! Remember to create them with the CHECK CONSTRAINTS Always Index the Foreign Key column!

Why Stored Procedures are a good idea? Avoid SQL Injection! If written in the right way! Enable plan reuse Optimization of Plan Cache Good for processing large amounts of data

Demo

Designing matters & Designing Good Indexes Clustered Indexes Always create them first! Avoid them on frequent updated columns Avoid creating with too many columns! They also impact your NonClustered Indexes Keep them narrow If possible use always growing values NonClustered Indexes Best when you want to retrieve small number of rows! The higher selectivity the better!

Designing matters & Designing Good Indexes Primary Keys Relational Integrity Clustering Keys Internal Mechanism for easily finding rows Primary Keys not necessarily needs to be the Clustering Key

Demo

Table Variables & Temporary Tables Used to hold temporary result sets No statistics maintained Indexes cannot be created Better usage for small workloads You can only refer them within their scope

Table Variables & Temporary Tables Used to hold temporary result sets Statistics maintained Indexes can be created Good if you have to handle medium sized or big workloads Depending the creation, can be accessed outside of the batch scope

Demo

Maintaining Indexes How do I know if they are being used? Do I have too many indexes in my Database? Remember. Indexes are hard to maintain What about missing indexes?

Speeding up data load Sometimes the best to do is just remove the indexes What is the purpose of the data load? When I would use HEAP Tables? Heaps can be great for high-performance data load and staging tables.

Looking for more resources? https://www.sqlskills.com/blogs/kimberly/ https://sqlperformance.com/author/paulwhitenzgmail-com https://www.red-gate.com/simple-talk/author/fabiano-amorim/ http://www.benjaminnevarez.com/

Thank you! Děkuji mnohokrát! Dankeschön! http://marcosfreccia.wordpress.com