Part II: Advanced DB2 for COBOL

"The difference between a query that runs in 0.01 seconds and one that runs in 10 minutes is rarely the SQL. It's whether you understand what the optimizer is doing with your SQL — and whether you've given it the information it needs to make good decisions."

What This Part Covers

Part II is the largest section of this book, and for good reason: DB2 performance is the single most common source of production incidents in COBOL shops. Seven chapters take you from understanding the optimizer's internals through advanced SQL techniques, locking and deadlock resolution, utility management, stored procedures, performance diagnosis, and production-tested application patterns.

This isn't a DB2 DBA book — it's DB2 from the application architect's perspective. You need to understand enough about the optimizer to write efficient SQL, enough about locking to prevent deadlocks, enough about utilities to know when a REORG will help (and when it won't), and enough about EXPLAIN output to diagnose the query that just blew your batch window.

Every chapter includes production-scale examples from Continental National Bank's 500-million-transaction-per-day environment and Pinnacle Health Insurance's 50-million-claim-per-month batch pipeline.

Chapters in This Part

Chapter Title Key Question
6 DB2 Optimizer Internals Why did your query change plans overnight?
7 Advanced SQL for COBOL What SQL features save you thousands of lines of COBOL?
8 Locking, Concurrency, and Deadlocks How do you prevent the 2am deadlock page?
9 DB2 Utilities When does REORG actually help, and when is it theater?
10 Stored Procedures and UDFs When should logic live in the database?
11 DB2 Performance Diagnosis How do you read EXPLAIN output and fix real problems?
12 DB2 Application Patterns What patterns survive at production scale?

Progressive Project

You'll design and implement the DB2 data model for your HA banking system: account tables, transaction history, audit logs, and the referential integrity constraints that keep the data clean. By Chapter 12, you'll have optimized batch and online access patterns, deadlock-free cursor management, and a utility scheduling strategy.

Prerequisites

Part I (especially Chapters 1 and 4). Basic embedded SQL and DB2 fundamentals from Books 1 and 2.

Chapters in This Part