Virtual techdays INDIA │ 18-20 august 2010 Filtered Indexes – The unexplored index … Vinod Kumar M │ Microsoft India Technology Evangelist – DB and BI.

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

Cardinality How many rows? Distribution How many distinct values? density How many rows for each distinct value? Used by optimizer A histogram 200 steps.
Understanding Parameter Sniffing Benjamin Nevarez Blog: benjaminnevarez.com 1.
Project Management Database and SQL Server Katmai New Features Qingsong Yao
Virtual techdays INDIA │ 9-11 February 2011 SQL 2008 Query Tuning Praveen Srivatsa │ Principal SME – StudyDesk91 │ Director, AsthraSoft Consulting │ Microsoft.
Connect with life Vinod Kumar M Technology Evangelist | Microsoft
Architecting a Large-Scale Data Warehouse with SQL Server 2005 Mark Morton Senior Technical Consultant IT Training Solutions DAT313.
Denny Cherry twitter.com/mrdenny.
SQL Server 2005 SP2 Israeli SQL Server User Group March 2005 Ami Levin
Relational Database Performance CSCI 6442 Copyright 2013, David C. Roberts, all rights reserved.
Module 8 Improving Performance through Nonclustered Indexes.
2 Avoiding Stored Procedure Recompiles Dr Greg Low Managing Director Solid Q Australia Session Code: DAT454.
Optimizing Queries Using Materialized Views Qiang Wang CS848.
Microsoft Access 2010 Building and Using Queries.
Microsoft TechForge 2009 SQL Server 2008 Unplugged Microsoft’s Data Platform Vinod Kumar Technology Evangelist – DB and BI
Ashwani Roy Understanding Graphical Execution Plans Level 200.
Module 5 Planning for SQL Server® 2008 R2 Indexing.
Table Indexing for the.NET Developer Denny Cherry twitter.com/mrdenny.
1 Chapter 10 Joins and Subqueries. 2 Joins & Subqueries Joins – Methods to combine data from multiple tables – Optimizer information can be limited based.
® Microsoft Access 2010 Tutorial 3 Maintaining and Querying a Database.
COMPREHENSIVE Access Tutorial 3 Maintaining and Querying a Database.
Denny Cherry twitter.com/mrdenny.
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.
Indexes and Views Unit 7.
Query Optimizer (Chapter ). Optimization Minimizes uses of resources by choosing best set of alternative query access plans considers I/O cost,
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.
Maciej Pilecki | Project Botticelli Ltd.. SELECT Bio FROM Speakers WHERE FullName=‘Maciej Pilecki’;  Microsoft Certified Trainer since 2001  SQL Server.
SQL SERVER DAYS 2011 Table Indexing for the.NET Developer Denny Cherry twitter.com/mrdenny.
Chapter 4 Indexes. Index Architecture  By default data is inserted on a first-come, first-serve basis  Indexes bring order to this chaos  Once you.
Connect with life Vinod Kumar Technology Evangelist - Microsoft
Connect with life Nauzad Kapadia Quartz Systems
Session 1 Module 1: Introduction to Data Integrity
Meta Data Cardinality Explored CSSQLUG User Group - June 2009.
Pinal Dave Mentor | Solid Quality India |
1 Indexes ► Sort data logically to improve the speed of searching and sorting operations. ► Provide rapid retrieval of specified rows from the table without.
Database Systems, 8 th Edition SQL Performance Tuning Evaluated from client perspective –Most current relational DBMSs perform automatic query optimization.
Retele de senzori Curs 2 - 1st edition UNIVERSITATEA „ TRANSILVANIA ” DIN BRAŞOV FACULTATEA DE INGINERIE ELECTRICĂ ŞI ŞTIINŢA CALCULATOARELOR.
SQL Server Statistics DEMO SQL Server Statistics SREENI JULAKANTI,MCTS.MCITP,MCP. SQL SERVER Database Administration.
October 15-18, 2013 Charlotte, NC SQL Server Index Internals Tim Chapman Premier Field Engineer.
Execution Plans Detail From Zero to Hero İsmail Adar.
Module 6: Creating and Maintaining Indexes. Overview Creating Indexes Understanding Index Creation Options Maintaining Indexes Introducing Statistics.
SQL Server Statistics DEMO SQL Server Statistics SREENI JULAKANTI,MCTS.MCITP SQL SERVER Database Administration.
SQL Server Statistics and its relationship with Query Optimizer
Chris Index Feng Shui Chris
Parameter Sniffing in SQL Server Stored Procedures
Microsoft SQL Server 2005 Advanced SQL Programming and Optimization
Tuning Transact-SQL Queries
Relational Database Design
SQL Server Statistics 101 Travis Whitley Senior Consultant, Oakwood Systems whitleysql.wordpress.com.
Microsoft Office Illustrated Introductory, Windows Vista Edition
T-SQL: Simple Changes That Go a Long Way
Module 4: Creating and Tuning Indexes
loooooooooooooong Introduction!
Introduction to SQL Server Management for the Non-DBA
Database Performance Tuning and Query Optimization
Building and Using Queries
Using Indexed Views & Computed Columns for Performance !
Cardinality Estimator 2014/2016
Statistics What are the chances
Statistics: What are they and How do I use them
Steve Hood SimpleSQLServer.com
Microsoft SQL Server 2014 for Oracle DBAs Module 7
Four Rules For Columnstore Query Performance
Recommending Materialized Views and Indexes with the IBM DB2 Design Advisor (Automating Physical Database Design) Jarek Gryz.
Chapter 11 Database Performance Tuning and Query Optimization
Why You Should Consider Implementing Indexed Views
Microsoft Office Illustrated Introductory, Windows XP Edition
Why You Should Consider Implementing Indexed Views
All about Indexes Gail Shaw.
Presentation transcript:

virtual techdays INDIA │ august 2010 Filtered Indexes – The unexplored index … Vinod Kumar M │ Microsoft India Technology Evangelist – DB and BI

 Filtered Indexes  What  Why  How  Filtered Indexes vs. Indexed Views  Plan Reuseability virtual techdays INDIA │ august 2010 A G E N D A

 Filtered Indexes are an index on a subset of rows in a table  WHERE clause in CREATE INDEX  Filtered Statistics are stats over a subset of rows  No auto-created filtered statistics virtual techdays INDIA │ august 2010 What is Filtered Index

 Improve query performance  Improve plan quality  Statistics are more accurate  Reduce index size  Reduce index maintenance cost  Large number of indexes are feasible  Query optimizer will choose the right index virtual techdays INDIA │ august 2010 Why use Filtered Index

 Sparse columns  Most rows contain NULL  Also when small subset of rows contain NULL (e.g. End Date)  IsDeleted flag columns  Categories of data in same table  Bikes, Clothing, Accessories  Sets of related properties  IN clause  Window Search - different types of properties  Ranges of data values  Dollar amounts, time ranges, date ranges  SharePoint lists (AllUserData table)  Table partitions virtual techdays INDIA │ august 2010 Why: Use Cases for Filtered Index

 ::= {Conjunct [AND Conjunct]}  ::= { Disjunct | Comparison }  ::= { column IN (constant, …)}  ::= {column constant}  ::= IS | IS NOT | = | | ! = | > | > = | ! > | < | < = | ! < }  = NULL not supported (even with setting) virtual techdays INDIA │ august 2010 How: Syntax

 age = 10 and category > 20  age = 10 and category > 20 and category < 50  age in (10, 20, 30)  age in (10, 20) and category in (15, 25) virtual techdays INDIA │ august 2010 Examples of Predicates

 Filtered indices can only be created as non-clustered indices.  Filtered indexes are not allowed on views unless they are indexed views.  Filtered indexes cannot be created on XML, spatial, or fulltext indexes.  If a filtered index is marked Unique, it means for all the qualifying rows, the index values are unique.  The filter expression cannot reference a computed column or UDT virtual techdays INDIA │ august 2010 Rules

 No ALTER INDEX to alter where clause  Use CREATE INDEX WITH DROP_EXISTING = ON  Online operations work  DTA recommends filtered indexes  Missing indexes don't report filtered index virtual techdays INDIA │ august 2010 Behaviors

 SET options required  ANSI_NULLS - ON  ANSI_PADDING - ON  ANSI_WARNINGS - ON  ARITHABORT - ON (set by ANSI_WARNINGS - ON)  CONCAT_NULL_YIELDS_NULL - ON  NUMERIC_ROUNDABORT - OFF  QUOTED_IDENTIFIER - ON  If not set correctly:  Insert/update/delete don't work  Optimizer doesn't consider plan  Can’t create index virtual techdays INDIA │ august 2010 SET Options

 Must match exactly  Filtered index col > 500  Col - no  Col and Col > yes  Don't get used with autoparameterization  If parameter could be outside the filter virtual techdays INDIA │ august 2010 Parameterized Queries

 Filtered Stats updated based on colmodctr  Filter predicate not considered  Filtered Stats use same sampling algorithm  Filter predicate not considered  Filtered stats can become  Out of date or updated too frequently  Not representative of true cardinality  Solution: Use scheduled stats update  with FULLSCAN virtual techdays INDIA │ august 2010 Filtered Statistics And Updating

 sys.indexes  sys.stats  sys.dependencies virtual techdays INDIA │ august 2010 Metadata

virtual techdays INDIA │ august 2010 DEMO: Filtered Index Explained and Explored !!! Vinod Kumar M

 Filtered Indices work best on columns where the Filter index criteria is simple and filters out a major portion of the rows in the table.  These work best in situations where columns are sparsely populated and index criteria is used to select only data that is populated with relevant values.  Generally using filtered indexes are useful for Sparse columns where most of the values in the column are NULL.  If the index needs to cover all rows in a table, use a regular index  If not, and the filtering condition is simple (fits within the filtered index grammar set), use a filtered index.  If filtering condition is complex, use an indexed view. virtual techdays INDIA │ august 2010 Best Practices

virtual techdays INDIA │ august 2010 Technology Comparison

 Filtered Indexes: an alternative to indexed views  Available in all SQL Server editions  Only simple filtering predicates  Variety of Uses  Sparse columns the biggest  Filtered Statistics: space saving over indexes  But watch sampling and updating virtual techdays INDIA │ august 2010 Summary

virtual techdays THANKS │ august