just-in-time indexes

28
Just-in-Time Indexes Understanding Indexes in KB_SQL March 2001 March 2001

Upload: raja

Post on 06-Jan-2016

28 views

Category:

Documents


0 download

DESCRIPTION

Just-in-Time Indexes. Understanding Indexes in KB_SQL March 2001. March 2001. Learning Objectives. What options do I have to improve query performance? The answer is…indexes. Review indexing strategies Introduce just-in-time indexes Discuss advantages and caveats. Improve Performance. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Just-in-Time Indexes

Just-in-Time Indexes

Understanding Indexes in KB_SQL

March 2001

March 2001

Page 2: Just-in-Time Indexes

Learning Objectives

• What options do I have to improve query performance?

The answer is…indexes.

• Review indexing strategies

• Introduce just-in-time indexes

• Discuss advantages and caveats

Page 3: Just-in-Time Indexes

Improve Performance

Why does my query run so slow?

Page 4: Just-in-Time Indexes

Query Results

Page 5: Just-in-Time Indexes

Show Plan/Stats: Query

Run query with Show Plan and Show Stats

Page 6: Just-in-Time Indexes

Show Plan: Results

Note: No index being used

Page 7: Just-in-Time Indexes

Show Stats: Results

Note: Selecting 9 of 25000 rows searched

Page 8: Just-in-Time Indexes

Show All Plans: Query

Run query with SHOW_ALL_PLANS to see if index is available

Page 9: Just-in-Time Indexes

Show All Plans: Results

Note: No indexes available

Page 10: Just-in-Time Indexes

Index Exists

Page 11: Just-in-Time Indexes

Define Index to KB_SQL

Add BY_NAME index in KB_SQL

Page 12: Just-in-Time Indexes

New Show Plan

Note: BY_NAME index is used, cost is reduced

Page 13: Just-in-Time Indexes

New Show Stats

Note: Selecting 9 of 9 rows searched

Page 14: Just-in-Time Indexes

New Show All Plans

Note: BY_NAME index available

Page 15: Just-in-Time Indexes

How do we improve performance if we don’t have sufficient indexes?

• What are the options?– Create supplemental table(s)– Build index– Create just-in-time index

• When will it be populated?

• How often should it be updated?

• Advantages and caveats?

Page 16: Just-in-Time Indexes

Create Supplemental Tables

• Create new table

• Join to “base” table

Page 17: Just-in-Time Indexes

Build the Index

• Benefits– Queries only look at key data which results

in faster searches

• Caveats– Time– Resources– Additional globals to maintain

Page 18: Just-in-Time Indexes

What if there is no index?

Page 19: Just-in-Time Indexes

What if there is no index? (cont)

Page 20: Just-in-Time Indexes

What if there is no index? (cont)

Page 21: Just-in-Time Indexes

Just-in-Time Indexes

• When will the index be populated?

• How often should the index be updated?

Page 22: Just-in-Time Indexes

Just-in-Time Indexes: Advantages and Caveats

• Advantages over traditional indexes– Add only the indexes that the user

demands– Reduce wasted effort to build indexes that

won’t be used• Caveats

– Does not provide up-to-the-minute data accuracy

– 2 or more queries to realize benefit

Page 23: Just-in-Time Indexes

Build the Just-in-Time Index

Page 24: Just-in-Time Indexes

Define the Index to KB_SQL

Page 25: Just-in-Time Indexes

New Show All Plans

Note: Two indexes available; BY_SUPPLIER is accepted based on constraint

Page 26: Just-in-Time Indexes

New Show Plan

Note: BY_SUPPLIER index is used

Page 27: Just-in-Time Indexes

New Show Stats

Note: Selecting 4 of 4 rows searched

Page 28: Just-in-Time Indexes

Summary

• Discussed options available to help improve query performance

The answer is…indexes.

• Reviewed indexing strategies

• Introduced just-in-time indexes

• Discussed advantages and caveats