The document discusses 5 ways to improve database performance through indexing: 1) addressing lookup imbalance by moving clustered indexes or adding included columns, 2) reducing scans on large indexes by adding alternative indexes, 3) using filtered indexes to improve performance on queries involving a subset of rows, 4) addressing missing index recommendations to optimize queries, and 5) indexing foreign keys to avoid performance issues during DML operations.
3. MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
• Founded 2008 by MSFT MVP Brian Knight
• Focused on the MSFT SQL Server Platform
• Provides services, training and software
• MSFT/HP “go to” partner:
• Gold Certified:
o BI
o Data Management
o SQL Performance
• Team led by multiple MVP’s
• Offices throughout the US with Corporate
HQ in Jacksonville, FL
Pragmatic Works Company History
8. Lookup Imbalance
• Excessive key lookups
– Exceed number of seeks
• Problems
– Increased CPU
– Increased IO
– Increased duration
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
9. Possible Solutions
• Ignore the problem
– Choose high key lookup rate
• Move clustered index
– Maybe the key is wrong
• Add included columns
– Improve NC indexes
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
10. Case Study 1
• What’s wrong?
• Do you see the pattern?
• What do you do?
– Move clustered index
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
11. Case Study 2
• What’s wrong?
• Do you see the pattern?
• What do you do?
– Move clustered index
– Add included columns
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
12. Case Study 3
• What’s wrong?
• Do you see the pattern?
• What do you do?
– Add included columns
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
13. November 6-9, Seattle, WA
Lookup Imbalance
• Demo
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
14. Lookup Imbalance Summary
• Key lookups should not exceed seeks
• Investigate “WHY” when they do
• Consider whether to:
– Move the clustered index
– Add included columns to non-clustered indexes
• Usage patterns will shift over time
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
16. Scan Heavy Indexes
• High scans on large indexes
– Exceed seeks
• Problems
– Increased IO
– Increased locking
• Potential deadlocks
– Affect page life expectancy
– Impact memory distribution
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
17. Case Study 1
• Metric is high, so what?
• How do you tie into performance counter?
– Sys.dm_db_index_usage_stats
– Plan cache
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
Access Methods:Full Scans/sec
18. Case Study 2
• What’s wrong?
• Why aren’t the other indexes used?
• Are the right indexes in place?
• What do you do?
– Examine execution plans
– Add in correct indexes
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
19. November 6-9, Seattle, WA
Scan Heavy Indexes
• Demo
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
20. Scan Heavy Indexes Summary
• High scans on indexes can impact performance
– Higher IO
– More locking
• More Blocking
• Possible Deadlocking
– Memory impacted
• Find the occurrences
– Identify indexes and analyze plans
– Add alternative indexes
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
22. Filtered Indexes
• Index with a WHERE clause
– Only includes filtered rows
– Decreases rows in index
• Effect
– Improved plan quality
– Improved storage
– Lower build time
– Less maintenance
• Benefit
– Scan of small set of data
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
23. Case Study
• New data coming this week
– Represents < 1% of rows
• Can’t rebuild indexes
– Statistics on new rows inaccurate
• Need high quality plans
– Indexes in place aren’t used
• What do you do?
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
24. Filtered Index Issue
• Filter Criteria
– Must be included
– Can not be parameterized
• Plan warning
– Unmatched indexes
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
25. November 6-9, Seattle, WA
Filtered Indexes
• Demo
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
26. Filtered Index Summary
• Consider filtered indexes for:
– Large indexes with limited range of use
– Tables with large number of new rows
• Improves index performance
– Smaller, lightweight, agile
– Improved plan quality
• Seeks over scans (small data over large data)
• Scans over seeks (tiny data over small data)
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
28. Missing Indexes
• Optimize through materialization
– Index versus statistics
• Three options
– Dynamic management views
– Database Engine Tuning
Advisor
– Plan Cache
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
30. November 6-9, Seattle, WA
Missing Indexes
• Demo
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
31. Missing Index Summary
• These are FREE recommendations
– Results of actual performance opportunities
– Provide opportunity to focus on other needs
• These are recommendations
– Index schema to ensure value
– Consolidate when possible
– Review associated queries
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
33. Indexing Foreign Keys
• Foreign keys enforcement
– INSERT
– UPDATE
– DELETE
• Performed in background
• Unseen until a problem
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
35. Case Study
Delete from SalesOrderHeader?
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
36. Case Study
Delete from SalesOrderDetail?
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
37. Case Study
Delete from SalesOrderHeaderSaleReason?
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
38. November 6-9, Seattle, WA
Indexing Foreign Keys
• Demo
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
39. Indexing Foreign Key Summary
• Foreign keys are important
– Enforce integrity of data
– Constraints on values
• Operations occur in background
– DELETEs often source of issues
– Can lead to deadlocks
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
40. Learn More About Indexes
MAKING BUSINESS INTELLIGENT
www.pragmaticworks.com
41. Services
Speed development through training, and
rapid development services from
Pragmatic Works.
Products
BI products to covert to a Microsoft BI
platform and simplify development on
the platform.
Foundation
Helping those who do not have the
means to get into information technology
achieve their dreams.
For more information…
Name: Jason Strate
Email: jstrate@pragmaticworks.com
Blog: www.jasonstrate.com
Resource: jasonstrate.com/go/indexing