Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
IBM DB2 9.7 Advanced Application Developer Cookbook

You're reading from  IBM DB2 9.7 Advanced Application Developer Cookbook

Product type Book
Published in Mar 2012
Publisher Packt
ISBN-13 9781849683968
Pages 442 pages
Edition 1st Edition
Languages
Toc

Table of Contents (15) Chapters close

IBM DB2 9.7 Advanced Application Developer Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
1. Application Development Enhancements in DB2 9.7 2. DB2 Application Techniques 3. General Application Design 4. Procedures, Functions, Triggers, and Modules 5. Designing Java Applications 6. DB2 9.7 Application Enablement 7. Advanced DB2 Application Features and Practices 8. Preparing and Monitoring Database Applications 9. Advanced Performance Tuning Tips

Using the soft invalidation and automatic revalidation support


In the earlier versions of DB2, whenever an object was altered or dropped, an exclusive lock was applied to ensure that no user accessed the object. This locking resulted in lock-waits or the rolling back of the transaction because of the deadlocks.

Getting ready

We need the SYSADM authority to modify the values for DB2 registry variables.

How to do it...

To enable or disable soft invalidation at the instance level, use the DB2 registry variable, DB2_DDL_SOFT_INVAL.

  • To enable soft invalidation at the instance level, set the value of the DB2_DDL_SOFT_INVAL registry variable to ON.

db2set DB2_DDL_SOFT_INVAL=ON
db2stop
db2start

  • To disable soft invalidation at the instance level, set the value of the DB2_DDL_SOFT_INVAL registry variable to OFF.

db2set DB2_DDL_SOFT_INVAL=OFF
db2stop
db2start

How it works...

In DB2 9.7, we have the soft invalidation feature to avoid these lock-waits or deadlocks. Upon activating soft invalidation using the registry variable DB2_DDL_SOFT_INVAL=ON in any transaction, the DDL operations, such as DROP TABLE, ALTER TABLE, and DETACH partitions on database objects will not be stuck because of a lock-wait (SQL0911N Reason Code 68) or a deadlock (SQL0911N Reason Code 2) while the modifying objects are being accessed by other transactions. This is because the current transaction will continue to access the original object definition while the new transaction will make use of the changed object definition of ALTER, DROP, or DETACH if the object being accessed is altered. During the DROP statement, the current transaction would still see the object until the completion of the execution of the transaction and all new transactions would fail to find the dropped object. This way, DB2 9.7 improves the application concurrency for DDL statements.

The following is the list of DDL statements for which soft invalidation is supported in DB2 9.7:

  • CREATE OR REPLACE ALIAS

  • CREATE OR REPLACE FUNCTION

  • CREATE OR REPLACE TRIGGER

  • CREATE OR REPLACE VIEW

  • DROP ALIAS

  • DROP FUNCTION

  • DROP TRIGGER

  • DROP VIEW

There's more...

As discussed in the earlier recipe, DB2 9.7 supports automatic object revalidation, based on the database configuration parameter's AUTO_REVAL setting.

Normally, the object would get revalidated whenever the application or the user accesses the invalid object, if AUTO_REVAL is set to DEFERRED. If we set AUTO_REVAL to IMMEDIATE, the objects get revalidated immediately after they become invalid.

You have been reading a chapter from
IBM DB2 9.7 Advanced Application Developer Cookbook
Published in: Mar 2012 Publisher: Packt ISBN-13: 9781849683968
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}