Db2 Troubleshooting
Plan or package points to wrong collection
Bind problems — package failures, plan mismatches, access-path regressions — come from the compile/bind/deploy chain getting out of sync.
What it means
- BIND turns SQL into an executable package; the plan connects programs to packages.
- Any break in compile → bind → deploy ordering causes -805/-818 class errors or slow plans.
Common causes
- Recompiled without rebind.
- Bound into the wrong collection.
- RUNSTATS changes picking a worse access path.
- Stale package after DDL change.
How to diagnose
- Compare bind timestamps with compile timestamps.
- Check plan PKLIST collections.
- EXPLAIN the statement to see the access path.
How to fix it
- Rebind after every compile.
- Deploy package and load module as a pair.
- Use PLAN_TABLE/EXPLAIN to verify access paths after RUNSTATS.
Example: Rebind after compile
BIND PACKAGE(PAYCOLL) MEMBER(PAYPGM) ACTION(REPLACE)
BIND PLAN(PAYPLAN) PKLIST(PAYCOLL.*) ACTION(REPLACE)
Package then plan, every time the program changes.
Interview tip
- Q: How would you troubleshoot a Plan or package points to wrong collection in production?
- A: I would compare compile and bind timestamps, check the plan collections, and EXPLAIN the access path.
Prevention checklist
- Automate bind in the deployment pipeline.
- Never deploy a load module without its package.
