Download presentation
Presentation is loading. Please wait.
1
Back to Indexes, the Original Culprit !
11/18/ :01 AM DBI406 Back to Indexes, the Original Culprit ! Amit Bansal CTO, eDominer Systems | Peopleware India President & Founder, © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
2
Agenda Indexing Scenario The Holy Trinity: Optimizer + Indexes + DTA
TechEd 2012 11/18/ :01 AM Agenda Indexing Scenario The Holy Trinity: Optimizer + Indexes + DTA Back to the Scenario: Bad design vs Good design Selectivity & Density: Does it make sense? Summary Image Source: © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
3
Agenda Demo: Indexing Scenario 1
TechEd 2012 11/18/ :01 AM Agenda Demo: Indexing Scenario 1 Optimizer’s choice of Physical Join Operator Indexing Scenario 2 Demo: Good Design vs Better Design The Optimizer’s choice of Indexes Demo: Indexing Scenario 3 How, When & Why did the Indexes become culprits? Demo: Clean up act ! Summary / Call to Action © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
4
demo Indexing Scenario 1 11/18/2018 11:01 AM
© 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
5
Optimizer’s choice of Physical Join Operator
TechEd 2012 11/18/ :01 AM Optimizer’s choice of Physical Join Operator NESTED LOOP JOIN when the outer input is small and the inner input has an index on the join key No restriction on operators; Inputs need not be sorted MERGE JOIN: Medium to large inputs Requires equality operator & inputs must be sorted on join predicate HASH JOIN: Large inputs Requires equality operator © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
6
Indexing Scenario 2 SELECT C.ContactID, C.FirstName, C.EmailPromotion
FROM Person.Contact2 AS C WHERE C.FirstName LIKE N'L%' AND C. Promotion = 1 AND C.ContactID < 10000 OPTION (MAXDOP 1) --returns 77 out of records 4.3 % (872) 25.2 % (5044) 50.04 % (9994)
7
Indexing Scenario 2 4.3 % (872) 25.2 % (5044) 50.04 % (9994)
SELECT C.ContactID, C.FirstName, C. Promotion FROM Person.Contact2 AS C WHERE C.FirstName LIKE 'L%' AND C. Promotion = 1 AND C.ContactID < 10000 OPTION (MAXDOP 1) -- Option 1 CREATE INDEX ContactComposite4 ON Person.Contact2(FirstName, Promotion) -- Option 2 CREATE INDEX ContactComposite5 ON Person.Contact2( Promotion, FirstName) 4.3 % (872) 25.2 % (5044) 50.04 % (9994)
8
Good Design vs Better Design
11/18/ :01 AM demo Good Design vs Better Design © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
9
The Optimizer’s choice of Indexes
TechEd 2012 11/18/ :01 AM The Optimizer’s choice of Indexes Single column index: True: FirstName LIKE 'L%' Promotion = 1 ContactID < 10000 False: FirstName LIKE ‘%L' ABS( Promotion) = 1 ContactID + 1 < 10000 © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
10
The Optimizer’s choice of Indexes
TechEd 2012 11/18/ :01 AM The Optimizer’s choice of Indexes Multi-column index: The index can be used to seek on the second column if there is an equality predicate on the first column True: FirstName = ‘L‘ AND Promotion = 1 Partially True: FirstName LIKE ‘L%‘ AND Promotion = 1 False FirstName LIKE ‘%L‘ AND Promotion = 1 © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
11
The Optimizer’s choice of Indexes
TechEd 2012 11/18/ :01 AM The Optimizer’s choice of Indexes Multi-column index: Our scenario © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
12
demo Indexing Scenario 3 11/18/2018 11:01 AM
© 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
13
How, When & Why did the indexes become culprits?
TechEd 2012 11/18/ :01 AM How, When & Why did the indexes become culprits? Too many Non-Clustered indexes? Did you strike a right balance between SELECT & UPDATE performance? Can you get rid of some redundant indexes? Image source: © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
14
IO Statistics LA 0 LB 1 LC 0 LD 2 LE 0 LF 1 LG 0 LH 2 LI 0 LJ 1 LK 0
TechEd 2012 11/18/ :01 AM IO Statistics LA LB LC LD LE LF LG LH LI LJ LK LM LN LO LP LQ LR LS LT LU LV LW LX LY LA LC LE LG LI LK LN LZ LA LF LJ LO LOA 1 LOB LOC LOD LS LZ LA LH LM LQ LU LZ © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
15
IO Statistics LA 0 LB 1 LC 0 LD 2 LE 0 LF 1 LG 0 LH 2 LI 0 LJ 1 LK 0
TechEd 2012 11/18/ :01 AM IO Statistics LA LB LC LD LE LF LG LH LI LJ LK LM LN LO LP LQ LR LS LT LU LA LC LE LG LI LK LN LP LB LF LJ LO LS LW LD LH LM LQ LU LY © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
16
11/18/ :01 AM demo Clean up act ! © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
17
Summary / Call to Action
TechEd 2012 11/18/ :01 AM Summary / Call to Action Browse this recording once again Try out the code snippets yourself Review your indexing strategies Implement the knowledge Try out various combinations in your ‘test environment’ © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
18
Amit Bansal @A_Bansal
19
mva Track Resources SQL Server 2012 Eval Copy Hands-On Labs @sqlserver
@TechEd_NA #msTechEd mva Microsoft Virtual Academy Get Certified!
20
Resources Learning TechNet http://northamerica.msteched.com
Connect. Share. Discuss. Microsoft Certification & Training Resources TechNet Resources for IT Professionals Resources for Developers
21
Complete an evaluation on CommNet and enter to win!
Required Slide Complete an evaluation on CommNet and enter to win!
22
MS Tag Scan the Tag to evaluate this session now on myTechEd Mobile
23
11/18/ :01 AM © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION. © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
24
11/18/ :01 AM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.