T-SQL: Simple Changes That Go a Long Way

Slides:



Advertisements
Similar presentations
Concepts of Database Management Seventh Edition
Advertisements

Midterm Review Lecture 14b. 14 Lectures So Far 1.Introduction 2.The Relational Model 3.Disks and Files 4.Relational Algebra 5.File Org, Indexes 6.Relational.
ADVANCE T-SQL: WINDOW FUNCTIONS Rahman Wehelie 7/16/2013 ITC 226.
Ashwani Roy Understanding Graphical Execution Plans Level 200.
SQL Server Indexes Indexes. Overview Indexes are used to help speed search results in a database. A careful use of indexes can greatly improve search.
Using Special Operators (LIKE and IN)
 Agenda 2/20/13 o Review quiz, answer questions o Review database design exercises from 2/13 o Create relationships through “Lookup tables” o Discuss.
Mark Inman U.S. Navy (Naval Sea Logistics Center) Session #213 Analytic SQL for Beginners.
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.
More Windowing Functions KEVIN MCCARTY. What are Windowing Functions Again? Introduced in SQL Server 2005 (SQL 2003 Standard) Used to provide operations.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
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.
IS201 Agenda: 09/19  Modify contents of the database.  Discuss queries: Turning data stored in a database into information for decision making.  Create.
05 | SET Operators, Windows Functions, and Grouping Brian Alderman | MCT, CEO / Founder of MicroTechPoint Tobias Ternstrom | Microsoft SQL Server Program.
SQL. Originally developed by IBM Standardized in 80’s by ANSI and ISO Language to access relational database and English-like non-procedural Predominant.
SQL Query Analyzer. Graphical tool that allows you to:  Create queries and other SQL scripts and execute them against SQL Server databases. (Query window)
Background Lots of Demos(That’s it.)
 Review quiz. Answer questions.  Discuss queries: ◦ What is a query? Turning data stored in a database into information for decision making. ◦ You: Completed.
A Glance at the Window Functions. Window Functions Introduced in SQL 2005 Enhanced in SQL 2012 So-called because they operate on a defined portion of.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
Scripting Just Enough SSIS to be Dangerous. 6/13/2015 Visit the Sponsor tables to enter their end of day raffles. Turn in your completed Event Evaluation.
6/13/2015 Visit the Sponsor tables to enter their end of day raffles. Turn in your completed Event Evaluation form at the end of the day in the Registration.
Data Integrity & Indexes / Session 1/ 1 of 37 Session 1 Module 1: Introduction to Data Integrity Module 2: Introduction to Indexes.
SQL IMPLEMENTATION & ADMINISTRATION Indexing & Views.
Eugene Meidinger Intermediate Querying: Going Beyond Select
T-SQL Power! Windows That Open Doors Adam
Data Analysis with SQL Window Functions Adam McDonald IT Architect / Senior SQL Developer Smith Travel
An Refresher and How-To Profile Data using SQL
Relational Database Design
© 2016, Mike Murach & Associates, Inc.
SQL Implementation & Administration
T-SQL: Simple Changes That Go a Long Way
Data Analysis with SQL Window Functions
The Ins and Outs of Indexes
Using SQL to Prepare Data for Analysis
Using Indexed Views & Computed Columns for Performance !
Marcos Freccia Stop everything! Top T-SQL tricks to a developer
The Ins and Outs of Indexes
The Key to the Database Engine
Cardinality Estimator 2014/2016
WINDOW FUNCTIONS ARE YOUR FRIENDS Dejan
WINDOW FUNCTIONS ARE YOUR FRIENDS Dejan
Indexing Fundamentals
The Ins and Outs of Indexes
Chapter 4 Summary Query.
Indexing for Beginners
Access: SQL Participation Project
Introduction to Window Functions
T-SQL gotchas and power-ups
Data Analysis with SQL Window Functions
Introduction to T-sql Window functionS
SQL Aggregation.
Contents Preface I Introduction Lesson Objectives I-2
Holger Klemt 801 Serverperformance Holger Klemt
Clustered Columnstore Indexes (SQL Server 2014)
EXECUTION PLANS Quick Dive.
Execution plans Eugene
The Ins and Outs of Indexes
Chapter 11 Managing Databases with SQL Server 2000
Build on-the-fly reporting with Dynamic SQL
All about Indexes Gail Shaw.
Advanced Database Topics
Introduction to SQL Server and the Structure Query Language
Intermediate Query Structure and Development
T-SQL: Simple Changes That Go a Long Way
Just Enough SSIS Scripting to be Dangerous.
The Ins and Outs of Indexes
Presentation transcript:

T-SQL: Simple Changes That Go a Long Way DAVE VALENTINE @ingeniousSQL ingeniousSQL.com linkedin.com/in/ingenioussql

Agenda Performance Heaps CLUSTERED INDEX NONCLUSTERED INDEX SARGable Functionality OUTPUT Table Valued Parameter Window Functions Common Table Expressions

Understand the Problem Before You Fix Create the Problem

About Dave… MCP 2 of 3 toward MCSA: SQL Server 2012 Database / BI Developer Adjunct Professor @IngeniousSQL Dave.Valentine@IngeniousSQL.com IngeniousSQL.com

Indexing CLUSTERED NONCLUSTERED Covering Filtered XML Spatial Full-text Column Store

Indexing Clustered Index Physical sorted order One per table PRIMARY KEY Fast key lookup

Indexing Heap Table without a CLUSTERED INDEX Poor performance Table Scans

Indexing Non-Clustered Index Another sorted copy of the data 16 key columns 999 per table dm_db_missing_index_details dm_db_missing_index_groups dm_db_missing_index_group_stats

Indexing Non-Clustered Index FOREIGN KEYs Covered Filtered SARGable http://www.sqlskills.com/blogs/kimberly/when-did-sql-server-stop-putting-indexes-on-foreign-key-columns/

Output INSERT, UPDATE, DELETE, MERGE @@IDENTITY SCOPE_IDENTITY IDENT_CURRENT INSERTED.* and DELETED.* http://technet.microsoft.com/en-us/library/ms177564.aspx

Table Valued Parameter Easily store and transfer rows of data User Defined Table Type UNIQUE and PRIMARY KEY Constraints No indexing No statistics Read only as procedure parameters http://technet.microsoft.com/en-us/library/bb510489.aspx

T-SQL Window Functions Ranking RANK, ROW_NUMBER, NTILE, DENSE_RANK http://technet.microsoft.com/en-us/library/ms189798.aspx Aggregate AVG, MIN, SUM, COUNT, STDEV, VAR, MAX http://technet.microsoft.com/en-us/library/ms173454.aspx Analytic LEAD, FIRST_VALUE, LAG, LAST_VALUE http://technet.microsoft.com/en-us/library/hh213234.aspx

Common Table Expressions CTE Simplify query syntax Multiple reference Recursive queries VIEW alternative http://technet.microsoft.com/en-us/library/ms190766(v=sql.105).aspx

Summary Heaps CLUSTERED INDEX NONCLUSTERED INDEX Covering Indexes Filtered Indexes SARGable INTO OUTPUT Table Valued Parameter Window Functions Common Table Expressions

Questions DAVE VALENTINE @ingeniousSQL ingeniousSQL.com linkedin.com/in/ingenioussql