Indexes: The Basics Kathi Kellenberger.

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

Module 3: Creating and Tuning Indexes. Planning Indexes Creating Indexes Optimizing Indexes.
Denny Cherry Manager of Information Systems MVP, MCSA, MCDBA, MCTS, MCITP.
Index Dennis Shasha and Philippe Bonnet, 2013.
EXECUTION PLANS By Nimesh Shah, Amit Bhawnani. Outline  What is execution plan  How are execution plans created  How to get an execution plan  Graphical.
Module 6 Implementing Table Structures in SQL Server ®2008 R2.
A HEAP OF CLUSTERS A look into heaps vs. clustered tables Ami Levin CTO, DBSophic X.
SQL Server Storage and Index Structures Physical Data Organization Indexes B-Trees SQL Server Data Access Clustered and Non-Clustered Creating, Altering,
Indexes Rose-Hulman Institute of Technology Curt Clifton.
Module 8 Improving Performance through Nonclustered Indexes.
With Michelle Ufford.  Sr. DBA for GoDaddy.com  Working with SQL for 6 years, focused on performance tuning and VLDB’s  Member of the PASS Performance.
Lecture 8 Index Organized Tables Clusters Index compression
Ashwani Roy Understanding Graphical Execution Plans Level 200.
Module 5 Planning for SQL Server® 2008 R2 Indexing.
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.
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.
Chapter 5 Index and Clustering
Session 1 Module 1: Introduction to Data Integrity
Indexing Fundamentals Steve Hood SimpleSQLServer.com.
Table Structures and Indexing. The concept of indexing If you were asked to search for the name “Adam Wilbert” in a phonebook, you would go directly to.
Indexes Part 2 What type of Indexes are there? Make sure you have the pages 2 & 3 of the Lab for Indexes in front of you before playing this presentation.
CS 405G: Introduction to Database Systems 12. Index.
October 15-18, 2013 Charlotte, NC SQL Server Index Internals Tim Chapman Premier Field Engineer.
APRIL 13 th Introduction About me Duško Mirković 7 years of experience.
Execution Plans Detail From Zero to Hero İsmail Adar.
SQL Basics Review Reviewing what we’ve learned so far…….
Module 6: Creating and Maintaining Indexes. Overview Creating Indexes Understanding Index Creation Options Maintaining Indexes Introducing Statistics.
Select Operation Strategies And Indexing (Chapter 8)
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.
When Good Design Goes Bad Bob Duffy Database Architect Prodata SQL Centre of Excellence March 2015.
Chris Index Feng Shui Chris
Understanding Data Storage
Indexes By Adrienne Watt.
Tree-based Indexing Hessam Zakerzadeh.
CS 540 Database Management Systems
SQL Server Query and Index Tuning
Accidental DBA Developer Edition
CS522 Advanced database Systems
Finding more space for your tight environment
Module 4: Creating and Tuning Indexes
The Ins and Outs of Indexes
The Ins and Outs of Indexes
Getting To Know Your Indexes
Lecturer: Mukhtar Mohamed Ali “Hakaale”
Indexes … WHERE key = Table Index 22 Row pointer Key Indexes
Data Warehouse Indexes
Session #, Speaker Name Indexing Chapter 8 11/19/2018.
Lecture 12 Lecture 12: Indexing.
Execution Plans Demystified
Indexing Fundamentals
PHP and MySQL.
The Ins and Outs of Indexes
Let’s Get Started! Rick Lowe
Microsoft SQL Server 2014 for Oracle DBAs Module 7
Please thank our sponsors!
Indexing for Beginners
Database systems Lecture 6 – Indexes
SQL DATA CONSTRAINTS.
Indexing For Optimal Performance
Weird Stuff I Saw While … Working With Heaps
Index Tuning Additional knowledge.
Denny Cherry twitter.com/mrdenny
CPS216: Advanced Database Systems
Clustered Columnstore Indexes (SQL Server 2014)
The Ins and Outs of Indexes
The Five Mistakes You are Probably Making with SQL Server
កម្មវិធីបង្រៀន SQL Programming ជាភាសាខ្មែរ Online SQL Training Course
All about Indexes Gail Shaw.
The Ins and Outs of Indexes
Presentation transcript:

Indexes: The Basics Kathi Kellenberger

Good things come in small packages…

Heaps B-Trees Two Types of Tables Heaps – not logically organized. Table without a clustered index B-Trees – used for clustered indexes and non-clustered indexes Data is organized by the key Heaps B-Trees

Heap M S D X A T F When looking for a value within a heap, have to scan the data to find it. If I am looking for A, I have to look at M, S, D, X to get to A No organization Good in some circumstances like loading staging tables

B-Tree M T D A F S X Balanced tree Hierarchy When I want to find a value, just have travel down the levels To find A, I start at M, is A less than M? Go to D. Is A Less than D? Go to A. When you add a clustered index to a table, it is organized as a B Tree A F S X

Find the Number Game How long to find a number when the numbers are random? How long when they are organized in a b-tree structure?

Clustered Index Structure M D T Non-Leaf Levels A F S X A D F Leaf Level M S T X Non-leaf levels contain the cluster key Leaf levels contain the data pages: cluster key + non-key columns

The best cluster key is ever-increasing M S D X A T F You can see lots of opinions about clustered index key. The best key is ever increasing. That means a date or ID column

The best cluster key is narrow and unique

The Best Clustered Key is Static CHANGES

Non-Clustered Indexes

Non-Clustered Indexes

Non-clustered Index Structure M D T Non-Leaf Levels A F S X A D F Leaf Level M S T X Non-leaf levels contain the Index Key Leaf levels contain the Index Key, Pointer to table row and Included Columns

Column Order Is Important! LastName FirstName City

Key Lookups When the index just isn’t enough

Covering Indexes

Best Practices Index foreign keys Index keys used in searches Avoid duplicate indexes Avoid indexes that are rarely used – unless there is a business reason DO NOT BLINDLY FOLLOW RECOMENDATIONS

Index Maintenance Maintenance Wizard Scripts Reorganize Rebuild Rebuild at 30% fragmentation Reorg > 10% and < 30% Ignore small tables Record what is done

Resources Glenn Berry Blog: http://sqlserverperformance.wordpress.com/ Expert Performance Indexing for SQL Server 2012 by Jason Strate (Apress) Ola Hallengren maintenance solution: https://ola.hallengren.com/ Duplicate index script: http://www.sql-server-performance.com/2013/find- duplicate-indexes-on-sql-server/