18
Thu, Apr
5 New Articles

TechTip: Cut to the Chase with DB2 Index Advisor PTFs

DB2
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

While index advice from the DB2 query optimizer is not new, the advice itself is much easier to capture and analyze with the new V5R4 tooling. A recent set of V5R4 PTFs simplifies the process even further.

With V5R4, capturing and collecting DB2 index advice is so simple that you don't even have to do anything. In past releases, you could find feedback on suggested indexes in optimizer debug messages within a job log or a database monitor collection. However, this feedback was available only if someone manually started a database monitor or turned on debug messages. Even once the advice was collected, an analyst had to deal with the complexities of extracting the advised index details of various job logs and database monitor files.

The DB2 query optimizer in V5R4 automatically logs all index advice for all queries to a system-wide repository. Just right-click the Database object in the iSeries Navigator tree and select the Index Advisor task to show the display in Figure 1. From this Advisor output screen, you can also directly create the advised index.

http://www.mcpressonline.com/articles/images/2002/CondenserV3--03300700.png

Figure 1: Right-click the Database object in the iSeries Navigator tree and select the Index Advisor for output. (Click images to enlarge.)

So that you are not overwhelmed with index advice, you can look at subsets of the DB2 index advice. Filtering the Index Advisor output is accomplished by launching the Advisor with a right-click on a table or schema (library) object. When the Index Advisor is launched from the table or schema level, the advisor will contain only those indexes advised for the selected table or the tables in the specified schema. This filtered index advice makes life much easier for the person who has to analyze and take action on the output provided by the DB2 for i5/OS Index Advisor.

Further simplifying the DB2 index advice is the capability delivered with recent V5R4 PTFs. The PTFs listed below deliver a new advisor feature known as the Index Advice Condenser:

  • i5/OS 5722-SS1: SI25391, SI25469, SI25470
  • iSeries Access for Windows: SI25949

This new Condenser simplifies use of the DB2 Index Advisor by analyzing the suggested indexes and trying to combine overlapping index advice into a single index recommendation. Overlapping index advice can occur when the query optimizer recommends indexes with the key columns in a different order or recommends indexes for different SQL requests that share some of the key columns. For example, a series of queries and SQL reports run against an inventory table results in the DB2 Index Advisor recommending two different indexes with the following keys:

  • Index #1—Key columns: item_color
  • Index #2—Key columns: item_color, item_size

In this case, creating a single index with key columns of item_color and item_size would cover both index recommendations. You don't have to manually correlate and combine advice for similar indexes because the Index Advice Condenser automates this process.

Not only will the Advice Condenser save you the time it takes to analyze the DB2 Index Advisor recommendations, but this new DB2 feature can also help you more efficiently utilize your server resources over the long term. Creating a single index that helps multiple queries and SQL statements is going to be better from a server resource point of view because a single index requires less storage and maintenance overhead than multiple indexes do. The Index Advice Condenser makes it much easier to create a single index that can potentially help multiple SQL requests.

Figure 2 shows the output of the Index Advice Condenser based on the raw index advice displayed in Figure 1 for the Customers table. Notice that the five indexes advised over the Customers table are reduced to four advised indexes by the Index Advice Condenser.

http://www.mcpressonline.com/articles/images/2002/CondenserV3--03300701.png

Figure 2: This is the output of the Index Advice Condenser based on the raw index advice displayed in Figure 1 for the Customers table.

You may be wondering why the recommended index over the custkey column was not merged into the last advised index in Figure 2, which contains key columns of Customer and Custkey. This behavior is due to the fact the Index Advice Condenser is limited by the "Leading Keys Order Independent" column returned in the DB2 Index Advisor output. This column contains those key column names that the DB2 Index Advisor is recommending to be at the beginning of the key definition for the index. The key columns in this "Leading Keys Order Independent" column can go in any order as long as they occupy the leading columns in the index key definition. The rest of the advised key columns can go in any order after the leading key columns. In this example, the Condenser is able to consolidate the first two rows of index advice into a single index with keys of Customer and Custkey since the "Leading Keys Order Independent" is the same for each advised index. In contrast, the advised index over just the Custkey column could not be merged into this same index because the leading key column for this index is Custkey, while the leading key for the consolidated index is Customers.

Condenser Interfaces

The Index Advice Condenser can be accessed programmatically or via a graphical interface. The graphical interface obviously is provided by iSeries Navigator. As you can see in Figure 3, the Condenser can be launched from the Index Advisor task menu.

http://www.mcpressonline.com/articles/images/2002/CondenserV3--03300702.png

Figure 3: The Condenser can be launched from the Index Advisor task menu.

To access the condensed index advice without iSeries Navigator, you can simply query a new view in the QSYS2 schema named CondensedIndexAdvice. This view will not be created in QSYS2 until the referenced i5/OS PTFs are applied on your server.

Here's an example of using this new view to retrieve the condensed index advice for a specific table:

SELECT * FROM qsys2.condensedindexadvice
  WHERE table_name='CUSTOMERS' AND table_schema='DBITSODATA'

Using the new Index Advice Condenser in conjunction with the system-wide Index Advisor will make it much faster for you to determine the right indexes to add to your database in order to maximize DB2 performance on your system.

Kent Milligan is a DB2 Technology Specialist on IBM's ISV Enablement team for System i. He spent the first seven years at IBM as a member of the DB2 development team in Rochester. He can be reached at This email address is being protected from spambots. You need JavaScript enabled to view it..

Kent Milligan
Kent Milligan is a Senior Db2 for i Consultant in the IBM Lab Services Power Systems Delivery Practice.  Kent has over 25 years of experience as a Db2 for IBM i consultant and developer working out of the IBM Rochester lab. Prior to re-joining the DB2 for i Lab Services practice in 2020, Kent spent 5 years working on healthcare solutions powered by IBM Watson technologies. Kent is a sought-after speaker and author on Db2 for i & SQL topics.
BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$0.00 Raised:
$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: