Book Image

IBM DB2 9.7 Advanced Application Developer Cookbook

Book Image

IBM DB2 9.7 Advanced Application Developer Cookbook

Overview of this book

With lots of new features, DB2 9.7 delivers one the best relational database systems in the market. DB2 pureXML optimizes Web 2.0 and SOA applications. DB2 LUW database software offers industry leading performance, scale, and reliability on your choice of platform on various Linux distributions, leading Unix Systems like AIX, HP-UX and Solaris and MS Windows platforms. This DB2 9.7 Advanced Application Developer Cookbook will provide an in-depth quick reference during any application's design and development. This practical cookbook focuses on advanced application development areas that include performance tips and the most useful DB2 features that help in designing high quality applications. This book dives deep into tips and tricks for optimized application performance. With this book you will learn how to use various DB2 features in database applications in an interactive way.
Table of Contents (15 chapters)
IBM DB2 9.7 Advanced Application Developer Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface

Improving performance by creating indexes on a DGTT


If we are processing a large amount of data from a temporary table, then we can use indexes to get performance benefits. We can create indexes on regular columns as well as on XML columns. The indexes will also be stored in the same table space in which the temporary table is defined.

How to do it...

Index creation on a DGTT is very similar to regular tables. Let's see how to do that:

  1. 1. Create a declared global temporary table:

    DECLARE GLOBAL TEMPORARY TABLE sample_xml (empno INT,
    sal_rise_date DATE,
    sal_dtls XML)
    ON COMMIT DELETE ROWS
    NOT LOGGED
    IN user_temp_tbsp;
    
    
  2. 2. Create an index on a relational column: Just like a regular table, use the CREATE INDEX statement to create an index on a temporary table. The following command creates an index on a relational column of a temporary table:

    CREATE INDEX SESSION.TEMP_REL_IDX ON SESSION.SAMPLE_XML (EMPNO);
    
    
  3. 3. Create an index on an XML column: We can also create indexes on XML columns. To create...