The Top 10 Things DBAs Should Know About Toad for IBM DB2 Written by Jeff Podlasek, senior product architect, Dell Software Abstract Toad for IBM DB2 is a powerful tool for the database administrator. This tech brief highlights some of its newer and lesser known features that provide great productivity benefits in the DBA s day-to-day work. Introduction Those of you working with DB2 who also have Oracle experience most likely have heard of Toad. For those of you who are working exclusively within the DB2 platform, the name Toad may not have much resonance. Historically, Toad was known primarily as a tool for Oracle developers. As a matter of fact, the name Toad was originally an acronym: Tool for Oracle Application Developers. But over the past few years, the Toad product family has branched out to support not only Oracle, but also SQL Server and DB2. It is also important to understand that the current Toad for IBM DB2 is not just a developer s tool, but also a very robust tool for database administrators. Whether you are managing DB2 running on Linux, UNIX, Windows or z/os, Toad for IBM DB2 provides the functionality you need to perform your day-to-day administration tasks with increased speed and accuracy. Toad for IBM DB2 provides all the features required for managing your DB2 objects, performing maintenance, and conducting performance tuning. This tech brief will reveal some of the unique database administration features found in Toad for IBM DB2 that greatly enhances the DBA s productivity.
Toad s group execute feature allows you to easily select multiple environments where you wish to run a script. Figure 1. Executing group execute from the SQL editor 1. Group execute The group execute functionality in Toad is a very useful productivity feature. Many times, a SQL statement or DDL script needs to be executed in multiple locations. The group execute feature allows you to easily select the environments where you wish to run the script (see Figure 1). Figure 2. Viewing the output of group execution for a selected location 2
Figure 3. Sending a script to the Remote Execution Wizard 1. Check the databases and subsystems you wish to execute against. 2. Click the run option from the editor. 3. Toad will automatically connect to the selected locations and run the script. 4. Review the script output from the individual locations. In the case of SQL selects, the results sets can even be compared to reveal any discrepancies. After execution, you can see if the run was successful. By selecting the location, you can view the results sets for only that environment, as shown in Figure 2. 2. Remote job execution In many cases, it is necessary to run maintenance jobs and database changes after hours. You may also be making changes to database objects with very large volumes of data, which makes it impractical to execute directly from your client. The remote job execution feature allows you to port your generated scripts down to your LUW server or to generate batch JCL for z/os jobs. This allows you to then schedule the jobs to run during the appropriate batch window with the dependency of the Toad client. Toad s remote job execution feature allows you to port your generated scripts down to your LUW server or to generate batch JCL for z/os jobs. Figure 4. Sending LUW scripts to the server via FTP 3
For LUW scripts, you will be prompted to FTP the script to the server. Figure 5. Generating z/os batch jobs Once you have a script generated, you can select the remote script execution button, as shown in Figure 3. LUW scripts For LUW scripts, you will be prompted to FTP the script to the server, as shown in Figure 4. z/os scripts For z/os scripts, you can save JCL to a PDS or submit directly to JES (see Figure 5). 3. Syncpoint restart The syncpoint restart option provides complete restart ability for your scripts. This is particularly useful when running extremely long complex scripts, or running scripts after hours where an operator may need to restart a job. Activating the syncpoint restart option To activate the syncpoint option, go to TOOLS\OPTIONS\Database\DB2\General and check the box to include syncpoint statements, as shown in Figure 6. Figure 6. Turning on syncpoint restart 4
Figure 7. SYNC points in script Once you ve activated the syncpoint option, all scripts will automatically include restart points, as illustrated in Figure 7. Using syncpoints The syncpoints perform a commit at each step, plus they provide the ability to restart in the event of a failure. If a script fails, simply select the restart option and specify the syncpoint from which you wish to restart. In the example in Figure 8, I forced a failure by changing the drop to an invalid table name. When the script failed, I corrected the error in the script and selected the restart button; then I was prompted for the syncpoint from which I wished to restart (see Figure 9.) Restart options for z/os scripts For z/os scripts, there are also options for restarting failed utilities, as illustrated in Figure 10. Once you ve activated the syncpoint option, all scripts will automatically include restart points. Figure 8. Restarting a script from a sync point 5
Toad enables you to set up a standard model for the name changes associated with migrating objects, so you can just apply them instead of having to retype them every time you create a new migration script. Figure 9. Specifying the syncpoint from which you d like to restart 4. Save and re-use transition rules Most DB2 shops have very specific naming conventions in order to differentiate between multiple DB2 environments. When moving objects, as an example, from a test database to a production database, you may have to change your schema/creator names from TEST to PROD, or the database may need to change from TSTDB to PRDDB, and so on. Toad enables you to set up a standard model for the name changes associated with migrating objects, so you can just apply them instead of having to retype them every time you create a new migration script. When you select an object for migration, you will get the transition rules window. Specify the changes you want applied to the objects and select the Save button to save the model (see Figure 11). The next time you set up a migration script, you can select the Load option and retrieve the saved model. 5. Change recovery You may have run into a situation where a change was made to a table that caused applications to fail because they were not updated to accommodate the new table structures. This requires you to roll out the change and return the table to its original definition. This can be a tedious, time-consuming option. A very useful feature in Toad is the ability to create recovery scripts in order to roll out changes or keep multiple versions of an object s structure. These scripts contain the original structure, along with all its dependencies, and can be simply executed to put the object back to its original state. Turning on the change recovery option To turn on script recovery, go to TOOLS\ OPTIONS\DATABASE\Advanced Admin, as shown in Figure 12. Figure 10. z/os utility restart options 6
When an object is altered, you will see a message at the top of the script indicating that a recovery script was created. Figure 11. Specifying transition rules in migration scripts Using a recovery script When an object is altered, you will see a message at the top of the script indicating that a recovery script was created, as indicated in Figure 13. The recovery dataset will contain all the DDL necessary to put the object back to the state it was in prior to the current change. This script can be put into the SQL editor and executed. Figure 12. Turning on the change recovery option 7
The z/os threads/ utilities and LUW application/ monitoring tabs give you a quick glance at current activity on a particular environment. Figure 13. Recovery message in script 6. Display current activity During a typical day, a DBA may be required to get a quick view of what s going on in the system. The z/os threads/ utilities and LUW application/monitoring tabs give you a quick glance at current activity on a particular environment. These features will even allow you to kill threads or force applications. Figure 14. Displaying and canceling active z/os threads 8
Figure 15. Displaying and terminating z/os utilities z/os features For z/os, you can display active threads and optionally cancel a thread if necessary, as shown in Figure 14. For z/os, you can display and terminate utilities as well (see Figure 15). LUW features For LUW, you have a few more options: you can view active applications, see active utilities, and get a graphical summary view of database activity, as shown in Figure 16 and Figure 17. For z/os, you can display active threads and optionally cancel a thread if necessary. Figure 16. Displaying active LUW applications 9
You can right click and generate commands for a specific database, tablespace or indexspace. Figure 17. LUW activity summary 7. DB2 z/os command processing There are a couple of different ways to generate and execute DB2 commands. Accessing z/os commands from the browser tree You can right click and generate commands for a specific database, tablespace or indexspace, as illustrated in Figure 18. Creating custom commands using code snippets You can also use the code snippets from the SQL editor to create custom commands, as shown in Figure 20. These custom commands can then be optionally saved for reuse. You can also create your own custom skeletons in the code snippets. Figure 18. Accessing z/os commands from the browser tree 10
Figure 19. Reviewing command output You can also use the code snippets from the SQL editor to create custom commands. Figure 20. Building custom commands with code snippets 11
Figure 21. Launching advanced tuning from the SQL editor Whether you re tuning SQL in z/os or LUW, you have the SQL compare features. 8. SQL tuning scenarios When it comes to tuning complex SQL statements, the general rule of thumb is to make small changes and test. Repeat the process until you get satisfactory performance in your query. The advanced SQL tuning options allow you to create multiple scenarios (iterations) of a SQL statement and then graphically compare them. Whether you re tuning SQL in z/os or LUW, you have the SQL compare features. To access the advanced tuning option, select the tuning icon from within the SQL editor (see Figure 21). For z/os, this will launch the Toad advanced tuning for DB2 z/os functionality. This module must be installed separately in addition to Toad. The access path and all relevant catalog statistics will be displayed in the main tuning window. There are additional tabs containing more details about the statement; plus, there is an advice tab to give you some basic tuning guidance, which can be applied and tested. Creating a new tuning scenario To begin the tuning process, select the create new scenario button (see Figure 22). This will copy your current statement into a new pane where it can then be modified and explained (see Figure 23). Another use for this is that the new scenario can be attached to a different subsystem if you want to test the query across different environments. Figure 22. Creating a new tuning scenario 12
Figure 23. Modifying SQL Comparing scenarios To compare the impact of the change against the original statement, select the compare scenarios button, shown in Figure 24. To begin the tuning process, select the create new scenario button. This will copy your current statement into a new pane where it can then be modified and explained. Figure 24. Selecting scenario compare 13
You can continue adding scenarios, making changes to the query, and testing until the desired access path and performance are achieved. Figure 25. Compare scenario summary The comparison will show a graphical summary of the performance impact of the change (see Figure 25); there are also additional tabs for comparing the actual statement structures and access paths side by side. The comparison will also validate the result sets for the different versions of the SQL. You can continue adding scenarios, making changes to the query, and testing until the desired access path and performance are achieved. Extracting z/os SQL directly from plans or packages for tuning You can also extract z/os SQL directly from plans or packages for tuning (see Figure 26). Figure 26. Extracting SQL from a package for advanced tuning 14
Figure 27. Accessing table partition analysis The Dell SQL Optimizer For DB2 LUW, the advanced tuning comes from Dell SQL Optimizer. SQL Optimizer must also be installed separately from Toad. From the SQL editor, you select the advanced explain option, as described above for z/os. This will launch SQL Optimizer. Select the show plan button from the toolbar to execute the explain option. 9. Analyze your DB2 data Toad for IBM DB2 includes several helpful features for analyzing your DB2 data. Partition table analysis If you are using the new partitioned table feature introduced with DB2 LUW 9.1, Toad s partition table analysis will allow you to see current data distribution and do what-if analysis by changing the partitioning ranges to see how it will affect the distribution (see Figure 27 and Figure 28). For DB2 LUW, the advanced tuning comes from SQL Optimizer. Figure 28. Reviewing data distribution 15
The Toad compression analysis feature shows the space savings that the DB2 compression feature could provide for you. Figure 29. Accessing compression analysis Compression analysis If you are using DB2 LUW 9.5 or greater, DB2 includes compression features that allow you to save on space and improve performance. The Toad compression analysis feature shows the space savings that the DB2 compression feature could provide for you, as well as the actual savings you are obtaining when you ve enabled the compression feature (see Figure 29 and Figure 30). Figure 30. Reviewing compression information 16
Figure 31. Accessing the histogram tool Histogram tool Toad includes a histogram feature which allows you to easily view the frequency of data values in your tables and views. From virtually any Toad results grid, you can right click in any cell and select Histogram Tool to invoke this feature (see Figure 31 and Figure 32). Toad includes a histogram feature which allows you to easily view the frequency of data values in your tables and views. Figure 32. Viewing histogram data 17
When you select the Datasets tab from the properties of a tablespace, the LISTCAT command will dynamically execute, giving you real-time VSAM space usage information. Figure 33. The datasets tab 10. DB2 z/os object and space information Toad includes DB2 z/os features that allow you to view space and administration information for your z/os objects. Dataset LISTCAT output This feature is available for z/os tablespaces and indexes. When you select the Datasets tab from the properties of a tablespace, the LISTCAT command will dynamically execute, giving you real-time VSAM space usage information, as shown in Figure 33. Space usage You can easily identify any space-related issues in Toad. Toad displays current and historic space usage for your z/os tables, tablespaces and indexes, as shown in Figure 34 and Figure 35. Figure 34. Current space-usage report 18
Figure 35. Space-usage growth report Real Time Statistics Advisor The Real Time Statistics Advisor (RTS) identifies objects that might be in need of maintenance, such as objects that need a REORG or COPY or those that need to have RUNSTATS run against them. To invoke this feature, select one or more databases from the database explorer and select the Real Time Statistics Advisor item from the rightclick menu, as shown in Figure 36. The Real Time Statistics Advisor (RTS) identifies objects that might be in need of maintenance. Figure 36. Accessing the Real Time Statistics Advisor 19
The RTS advisor includes tablespace and index tabs that show additional details. Figure 37. The Real-time Statistics Advisor s summary display The RTS advisor includes tablespace and index tabs that show additional details (see Figure 37). Generating scripts to take corrective actions is easily accomplished using right-click menus (Figure 38). Figure 38. Tablespace metrics showing the right-click menu 20
Figure 39. RTS threshold criteria Toad includes a set of threshold criteria that is used to identify severe and warning conditions. Toad includes a set of threshold criteria that is used to identify severe and warning conditions (see Figure 39); these criteria can be modified for your environment. Figure 40. Launching Foglight Performance Analysis for DB2 from Toad 21
Foglight Performance Analysis for DB2 LUW reveals enterprise-level performance at a glance. Figure 41. Foglight Performance Analysis for DB2 11. Bonus feature: DB2 LUW workload analysis Toad for IBM DB2 integrates with Foglight Performance Analysis for DB2 (see Figure 40). Foglight Performance Analysis for DB2 LUW reveals enterpriselevel performance at a glance (see Figure 41). A powerful, web-enabled enterprise administration and alerting interface lets you create custom dashboards and reports as well as automate and track performance-tuning and problemresolution initiatives. Its DB2 workload analysis tool identifies even the most elusive and complicated bottlenecks and inefficiencies. Built-in workflows and pre-compiled action plans guide you through response-time and wait event analysis, so you can quickly understand existing or developing conditions and how to resolve them. Foglight Performance Analysis for DB2 is a separate product that enables you to: Accelerate problem resolution with deeper visibility and intelligent, baselinedriven alerts Prevent performance problems with advanced trend analysis Reduce costs by maximizing the performance of existing hardware, avoiding unnecessary upgrades or additional purchases Increase productivity by enabling each DBA to manage a greater number of databases Gain a precise understanding of the user experience, especially when performance problems occur For more information on Foglight Performance Analysis for DB2, or to download a free trial, please visit software.dell.com/products/foglightperformance-analysis-for-db2-luw/. 22
Conclusion This technical brief highlighted some of the more unique productivity features available in Toad for IBM DB2. These features only scratch the surface of the full capabilities Toad for IBM DB2 provides. To access additional information about the full capabilities of these products, go to software.dell.com/ products/toad-for-db2-zos/ or software. dell.com/products/toad-for-db2/. You ll find product details, recorded demos and trial downloads. About the author Jeff Podlasek is a senior product architect on the Toad for DB2 products at Dell Software. Jeff has more than 20 years of software development experience. He has developed products and managed development teams working on DB2 tools since the 1980s. Jeff is a regular contributor to the Toad for DB2 forums at www.toadfordb2.com. Jeff is a regular contributor to the Toad for DB2 forums at www. toadfordb2.com. 23
For More Information 2013 Dell, Inc. ALL RIGHTS RESERVED. This document contains proprietary information protected by copyright. No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying and recording for any purpose without the written permission of Dell, Inc. ( Dell ). Dell, Dell Software, the Dell Software logo and products as identified in this document are registered trademarks of Dell, Inc. in the U.S.A. and/or other countries. All other trademarks and registered trademarks are property of their respective owners. The information in this document is provided in connection with Dell products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of Dell products. EXCEPT AS SET FORTH IN DELL S TERMS AND CONDITIONS AS SPECIFIED IN THE LICENSE AGREEMENT FOR THIS PRODUCT, DELL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL DELL BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS INTERRUPTION OR LOSS OF INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF DELL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Dell makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and product descriptions at any time without notice. Dell does not make any commitment to update the information contained in this document. About Dell Dell Inc. (NASDAQ: DELL) listens to customers and delivers worldwide innovative technology, business solutions and services they trust and value. For more information, visit www.dell.com. If you have any questions regarding your potential use of this material, contact: Dell Software 5 Polaris Way Aliso Viejo, CA 92656 www.dell.com Refer to our Web site for regional and international office information. 24 TechBrief-ToadDB2-Top10-US-KS-2013-06-17