Modernization Hub

BIND - Database package creation

Enhanced Definition

BIND is the process in IBM DB2 for z/OS that converts SQL statements embedded in an application program (like COBOL or PL/I) into an executable form, known as an **access path**. This process creates a `package` or `plan` in the DB2 catalog, defining how DB2 will efficiently access data for those SQL statements.

Key Characteristics

    • Input: The primary input is a Database Request Module (DBRM), which contains the SQL statements extracted from the application program by the DB2 precompiler.
    • Output: The BIND process generates a package (or an older plan) that is stored in the DB2 catalog and contains the optimized access paths.
    • Optimization: During BIND, the DB2 optimizer analyzes the SQL statements, database statistics, and available indexes to determine the most efficient method (access path) for data retrieval and manipulation.
    • Static SQL: BIND is primarily used for static SQL, where SQL statements are fixed and known at compile time. Dynamic SQL undergoes a similar optimization process at runtime.
    • Dependencies: The resulting package records dependencies on specific database objects (tables, views, indexes), ensuring that if these objects change, the package can be flagged as invalid.
    • Privilege Requirement: The user or ID performing the BIND operation must have appropriate DB2 privileges (e.g., BINDADD, BINDAGENT, BIND on the collection, and necessary object privileges like SELECT, INSERT, UPDATE, DELETE).

Use Cases

    • New Program Deployment: After a new COBOL program with embedded SQL is compiled, its DBRM must be bound to create the necessary DB2 package before the program can be executed.
    • Application Code Changes: Whenever the SQL statements within an existing application program are modified, the program must be re-precompiled, re-compiled, and its DBRM re-bound to update the corresponding DB2 package.
    • Database Schema Modifications: If underlying database objects (e.g., tables, indexes) are altered, or new indexes are created, a REBIND operation can be performed on affected packages to allow DB2 to re-optimize access paths based on the new structure.
    • Performance Tuning: Rebinding a package can be used to force the DB2 optimizer to re-evaluate access paths, especially after RUNSTATS has been executed to update table and index statistics, potentially leading to improved query performance.

Related Concepts

BIND is a crucial step in the application development lifecycle for DB2 on z/OS, directly linking application code to the database. It takes the DBRM (generated by the DB2 precompiler from COBOL/PL/I source) as input and stores the optimized package in the DB2 Catalog. This package is then referenced by the application program at runtime to execute its SQL, making JCL essential for invoking the DB2 BIND utility. The output, the access path, dictates how DB2 interacts with tables and indexes, directly impacting application performance.

Best Practices:
  • Utilize Packages: Always bind into packages rather than plans for better modularity, easier version control, improved concurrency, and reduced contention in the DB2 catalog.
  • Maintain Current Statistics: Ensure RUNSTATS is regularly executed on all relevant tablespaces and indexes to provide the DB2 optimizer with accurate and up-to-date statistics, which are critical for choosing optimal access paths during BIND.
  • Monitor Access Paths with EXPLAIN: Use the EXPLAIN facility to analyze the access paths chosen by the optimizer for critical SQL statements, identifying potential performance bottlenecks and opportunities for index creation or SQL tuning.
  • Version Control DBRMs: Treat DBRMs as critical artifacts and manage them under a robust version control system alongside their corresponding application source code.
  • REBIND Strategically: Consider performing a REBIND on affected packages after significant database schema changes, RUNSTATS updates, or DB2 subsystem upgrades to leverage new optimizations or access paths.
  • Grant Minimal Privileges: Adhere to the principle of least privilege by granting only the necessary BIND and object privileges to the user IDs or groups responsible for performing bind operations.

Related Vendors

IBM

646 products

Tone Software

14 products

Applied Software

7 products

Trax Softworks

3 products

Related Categories

Operating System

154 products

Databases

211 products

Automation

222 products

Encryption

41 products