Skip to content
DB2 & data

BIND

Preparing a program's SQL for execution, working out how each statement will access the data and storing the result.

Also written package, plan, rebind

Binding is the step between compiling a program with embedded SQL and being able to run it. It takes the database request module produced during precompilation and creates a package that DB2 will use at run time.

The important work is done by the optimiser. For each statement, DB2 decides how it will actually get the data: which index to use, in what order to join tables, whether to scan. That decision is made once, at bind time, and stored, so the cost is not paid on every execution.

The consequence is that a program's performance is fixed at bind. If a table grows enormously or an index is added, the stored plan may no longer be the best one, and rebinding lets the optimiser reconsider with current information. Rebinding after significant data changes is routine housekeeping.

Binding also checks authorisation. The bind confirms the program is permitted to touch the tables it references, so access can be granted to the program rather than to every user individually.

Packages are collected into plans, which is what a job or transaction actually names.

Browse all 115 terms

Learn this properly.

Use BIND for real in Mainframe101, in your browser, with Zed beside you. Join the waitlist.

Early access and updates. No spam, unsubscribe any time.