280 likes | 382 Views
Understand the power of just-in-time indexes to enhance query performance in KB SQL. Learn when and how to create supplemental tables, build indexes, and optimize search processes. Explore benefits and considerations for implementing just-in-time indexes effectively.
E N D
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 Why does my query run so slow?
Show Plan/Stats: Query Run query with Show Plan and Show Stats
Show Plan: Results Note: No index being used
Show Stats: Results Note: Selecting 9 of 25000 rows searched
Show All Plans: Query Run query with SHOW_ALL_PLANS to see if index is available
Show All Plans: Results Note: No indexes available
Define Index to KB_SQL Add BY_NAME index in KB_SQL
New Show Plan Note: BY_NAME index is used, cost is reduced
New Show Stats Note: Selecting 9 of 9 rows searched
New Show All Plans Note: BY_NAME index available
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?
Create Supplemental Tables • Create new table • Join to “base” table
Build the Index • Benefits • Queries only look at key data which results in faster searches • Caveats • Time • Resources • Additional globals to maintain
Just-in-Time Indexes • When will the index be populated? • How often should the index be updated?
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
New Show All Plans Note: Two indexes available; BY_SUPPLIER is accepted based on constraint
New Show Plan Note: BY_SUPPLIER index is used
New Show Stats Note: Selecting 4 of 4 rows searched
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