Skip to main content

Process your DB2 for iSeries Indexes in Parallel

Kent Milligan, DB2 UDB Technology Specialist, IBM Japan, Software Group
Photo: Kent Milligan
Kent Milligan is a DB2 UDB Technology Specialist in PartnerWorld® for Developers, iSeries. Kent spent the first eight years of his IBM career as a member of the DB2 development group in Rochester. He speaks and writes regularly on various iSeries and AS/400e relational database topics. You can reach him at kmill@us.ibm.com.

Summary:  With DB2 for iSeries, parallel processing is useful for more than just queries. Batch processing, loads, and index builds can all occur much faster if you use multiple processors to do that work.

Date:  09 Jan 2003
Level:  Introductory
Activity:  711 views

© 2003 International Business Machines Corporation. All rights reserved.

Introduction

When people think of parallel processing in a database engine, they immediately think of improved query response time by having multiple processors working on a single query. What people tend to overlook is that parallel processing can speed up index processing, too, and thus improve the overall performance of your database server. With IBM® DB2® Universal DatabaseTM (UDB) for iSeriesTM, it is possible to use CPUs for index processing. Specifically DB2 UDB for iSeries can use multiple processors when creating indexes and when maintaining indexes as the underlying data changes. The ability to create and maintain indexes in parallel applies to both the traditional binary radix and encoded vector index structures.

DB2 UDB for iSeries parallel processing is only available on iSeries servers where the DB2 Symmetric MultiProcessing (DB2 SMP) licensed feature has been purchased, installed, and activated, as described in Enabling parallel processing.


Parallel index creation

DB2 UDB for iSeries can use parallel processing for the creation of both SQL indexes and keyed-logical files (that is, the CRTLF command). Parallel index processing is accomplished by logically breaking the underlying table into multiple segments of data, and then each process builds the index key values for the assigned table segment. The work performed by each parallel process is then merged together to complete the final index structure.

As you can see in Figure 1, using additional CPU resources can substantially reduce the amount of time it takes to create an index. This ability becomes very important in a very large database environment, or in a recovery scenario where recreating the indexes needs to occur as fast as possible.


Figure 1. Index build times are greatly improved with parallelism enabled
Index build times are greatly improved with parallelism enabled

Parallel index maintenance

Index maintenance is the task of changing the index key to reflect changes (usually caused by insert, update, or delete) to the associated database row. If an order number for a customer is changed or if a new order for a customer is added to the database, all indexes that include the order number column as a key field must be updated. The maintenance (or update) of the indexes factors into the overall transaction time associated with adding or changing an order.

If more than one index isaffected by a database row change, the maintenance of those indexes occurs serially, by default, one index at a time. First, the order number change is propagated to IndexA. After the change to IndexA is completed, the order number is propagated to IndexB, and so on.

Parallel index maintenance involves maintaining multiple indexes concurrently. The order number changes for a customer can be propagated to IndexA and IndexB simultaneously. This concurrent index maintenance processing reduces the total amount of time it takes to get an order number change through the database. Parallel index maintenance trades resources for time, increasing the I/O velocity of a given application or transaction.

Figure 2 reflects the time savings that can be achieved by maintaining multiple indexes in parallel. In Figure 2, new rows are being loaded into a table with multiple indexes and parallel index maintenance improves the load time by two to three times.


Figure 2. Load time improves when index maintenance occurs in parallel
Load time improves when index maintenance occurs in parallel

DB2 UDB for iSeries uses parallel index maintenance only when the application:

  • Is performing blocked inserts (or writes) of eight or more rows.
  • The associated table has two or more indexes defined over it.

Blocked inserts are commonly found in batch update and data warehouse load processes, so parallel index maintenance will have the biggest performance impact in these environments.

Tip: If a load process is adding more than 20% new rows to a table, it's usually recommended to drop the indexes prior to the load and then use parallel processing to rebuild the indexes after the load process has completed.


Enabling parallel processing

After you install the DB2 SMP feature, there are several different ways to activate parallel processing so that parallel index builds and maintenance can be performed.

At a system level

By default, the amount of parallel processing is controlled at a system-wide level via the QQRYDEGREE system value. If that system value is set to a value other than *NONE, DB2 UDB will use parallel processing when maintaining and building indexes. The CHGSYSVAL (Change System Value) commands can be used to change the setting of the QQRYDEGREE system value. Here are the values that you can specify to enable parallel index processing:

  • *MAX - The DB2 UDB engine can use all of the CPU processors and all of the memory available to the job (connection) during parallel index maintenance and build.
  • *OPTIMIZE - A "good neighbor" setting. The DB2 UDB engine will use its job share of the CPU processors and memory.
  • *NBRTASKSn - This sets the maximum number of CPU processors that the DB2 UDB engine can use. This is not a valid value for the QQRYDEGREE system value.
  • *NONE - This is the default value. No parallel processing is used for index processing.

At a job or connection level

If you want to restrict parallel processing to an individual job or connection, then use the CHGQRYA (Change Query Attributes) CL system command or a QAQQINI file to enable parallel processing for a job or connection. These interfaces override the system value setting.

The DEGREE parameter on the CHGQRYA CL command accepts the same values as the system value. If the following CHGQRYA command is executed in a job, then the parallel degree is set to *MAX only for that job, regardless of the system value:

CHGQRYA DEGREE(*MAX)

This command can be issued multiple times within a job to turn parallelism on and off.

The QAQQINI file also lets you specify parallel processing for an individual job or connection. Like .INI files found on your PC that are used to store the configuration settings that control the behavior (colors, window size, etc.) of PC tools and applications, the QAQQINI file can be used to influence the behavior of the database engine - in this case, the parallel processing behavior. These QAQQINI configuration settings can be saved and applied dynamically across multiple database requests.

The fact that the QAQQINI file is just a normal database table means you can dynamically change the values of different attributes as required by your environment. It's also very flexible, because normal database interfaces can be used to change the values of an QAQQINI attribute. The following SQL statement demonstrates how to use the QAQQINI file to set the parallel processing degree to *OPTIMIZE:

UPDATE MyLib.QAQQINI SET QQVAL = '*OPTIMIZE' WHERE QQPAM='PARALLEL_DEGREE'

There's no limit on the number of times that an attribute value can be changed during a job or connection. For more information on creating and using the QAQQINI file, see DB2 UDB for iSeries Database Performance and Query Optimization Guide or the following Web site: http://www.iseries.ibm.com/developer/bi/tuner/index.html


Conclusion

This article has shown the value of the parallel processing provided by the DB2 SMP feature for non-query workloads. To enable parallel index processing, activate parallel processing via one of the interfaces described in this article before you build indexes, load data, or perform batch processing. By doing so, you can more fully utilize CPU resources on a multi-CPU server and speed up performance.


About the author

Photo: Kent Milligan

Kent Milligan is a DB2 UDB Technology Specialist in PartnerWorld® for Developers, iSeries. Kent spent the first eight years of his IBM career as a member of the DB2 development group in Rochester. He speaks and writes regularly on various iSeries and AS/400e relational database topics. You can reach him at kmill@us.ibm.com.

Comments (Undergoing maintenance)



Trademarks  |  My developerWorks terms and conditions

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Information Management
ArticleID=14220
ArticleTitle=Process your DB2 for iSeries Indexes in Parallel
publish-date=01092003
author1-email=
author1-email-cc=

My developerWorks community

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Special offers