Professional Documents
Culture Documents
Architecture of db2 For Z Os
Architecture of db2 For Z Os
DB2 Architecture
• Controls connections to other MVS subsystems running under different address spaces.
• e.g. CICS, TSO etc.
• Handles System startup and shutdown.
• Manages the System Log
• DB2 uses two Active Log datasets. When one Active Log is full, DB2 automatically switches to
other Log.
• While the second Log Dataset is being written to, the first dataset is backed up on an Archive Log
which is usually a Cartridge or disk.
• DB2 maintains two copies of both the Active and Archived Datasets.
• It allocates a thread at the beginning of program execution.
• Monitors the progress of execution.
Database Services
Pre-compiler :
• Input : The source program written in the host language e.g. COBOL, PL/I etc. is the input to the
Pre-compiler.
• Outputs : The outputs are the modified Source Program and DBRMs.
• Process : Pre-compiler strips out all the embedded SQL statements from the host language
program, replaces them with host language CALL statements and using the extracted SQL
statements, constructs a Database Request Module ( DBRM )
• The inserted CALL statements issue a call to the DB2 Language Interface Module.
Source
Module
Modified DBRM
Source
Module PRECOMPILER
CATALOG
Bind
Compiler
Object PACKAGE
Module
Module
Modified DBRM
Source PRECOMPILER
Module
CATALOG Bind
Compiler
Object
Module
Other List Of
Object Packages
Linkage Modules
Editor Bind
Application
Load Plan
Module
Database Services ( Contd.)
Bind :
• Input : Source DBRMs constructed by the Pre-compiler.
• Outputs: Package and Application Plan.
• Process : There are two distinct stages in which Bind can be used.
• Bind compiles the DBRMs into a Package.
• It then compiles a list of packages into an Application Plan.
• The Package and Application Plan are stored in the Directory.
• A Package is a compiled form of the Database Requests.
• Package contains complete information regarding the runtime access path ( access strategy )
of the SQL statements in the DBRM.
• Thus Bind is really an Optimizing Compiler.
• Bind performs the compilation in four steps.
• 1) Syntax checking
• 2) Optimization : Bind Optimizer chooses the optimum access path from the database
statistics stored in the various Catalog Tables.
Database Services ( Contd.)
• Bind ( Contd. )
A special utility called RUNSTATS is provided for gathering this statistics. e.g. The optimizer may
choose to have a sequential table scan instead of using an Index defined on a table.
• 3) Package generation
• 4) Authorization checking
Bind checks that the owner of the bind is allowed to perform the operations requested in the
SQL statements that constitute the DBRMs to be bound.
• If an object is dropped, all Application Plans that were using the object are marked by DB2 as
invalid.
• At run-time, when a program requests to load such an invalid plan, DB2 automatically invokes
Bind and the corresponding Application Plan is rebound to use an alternative access path.
• However if a new object is created, DB2 does not automatically start using it.
• e.g. If a new Index is defined on a table, all concerned Application Plans must be explicitly
rebound by the developer for DB2 to be able to use the Index.
Database Services ( Contd.)
• Runtime Supervisor
• It’s job is to oversee the running of the Application Program.
• When the runtime supervisor comes across an SQL statement, it loads the corresponding
Application Plan,
• and as per the plan requests the Data Manager to perform appropriate operations.
• Data Manager
• Performs functions such as search, retrieval and update of data, index maintenance.
• Buffer Manager
• Responsible for the physical transfer of data between DASD and virtual memory.
• It keeps the frequently read and updated pages in the main memory to minimize physical
I/Os.
• The buffer pages that are Least Recently Used
( LRU ) are swapped out first.
• It uses techniques such as read ahead buffering for better performance.
• If the required Application Plan is not present in the Bufferpools at run-time, Buffer Manager
loads the Plan and passes control to the Environment Descriptor Manager.
Database Services ( Contd.)
• Environment Descriptor Manager.
• The Plan is physically stored as Skeleton Cursor Table or SKCT and a Package is called a
Skeleton Package Table or SKPT.DB2 loads the copy of this in the EDM pool
Source Module
EXEC SQL
.....
END EXEC
Source Module
EXEC SQL
.....
END EXEC Language Interface
Module
Source Module
EXEC SQL
.....
END EXEC Language Interface
Module
Runtime Supervisor
Source Module
EXEC SQL
.....
END EXEC Language Interface
Module
Runtime Supervisor
Data Manager
Source Module
EXEC SQL
.....
END EXEC Language Interface
Module
Runtime Supervisor
Data Manager
Buffer Manager
Source Module
EXEC SQL
.....
END EXEC Language Interface
Module
Runtime Supervisor
Data Manager
Buffer Manager
EDM Manager
Source Module
EXEC SQL
.....
END EXEC Language Interface
Module
Runtime Supervisor
Data Manager
Buffer Manager
EDM Manager
Application Plan/Package
DB2 Objects
Storage Group
Tablespace Indexspace
Table Index
View Synonym
Db2 Objects
• A DB2 sub-system consists of several User and System Database.
• A mandatory system database is the Catalog Database.
• Each database is divided into Tablespaces and Index spaces.
• Every Tablespace contains one or more Tables.
• Every Index space contains exactly one Index.
• Every Tablespace or Index space is divided into a set of Pages.
• A page is also called as a block or unit of physical I/O.
• All Index space pages are of 4K bytes in size.
• All Tablespace pages are either of 4K bytes or 32K bytes in size.
• Every Table or Index is wholly contained in their respective Tablespace or Indexspaces.
• Every Table and all of it’s associated Indexes are wholly contained in the same Database.
Db2 Objects(Contd.)
starts
Storage management
Accounting/statistics/
performance traces
Startup/shutdown
checkpointing/recovery
DB2 - Allied Address Spaces
WebSphere BATCH / TSO IMS CICS
Application DB2 Control Control
Server Utilities Region Tx Tx Tx
Application TSO ONLINE MPP A B C
TSO BATCH BMP
CAF Fast Path
DL/I
Batch
DB2
Locking
System Services Database Services Services
(IRLM)
User
BSDS LOG DBs CAT DIR
DIRECTORY CATALOG
TABLES TABLES 4 KB ROWS
32 KB ROWS
USER USER
TABLES TABLES
The DB2 Catalog defines itself, DSNDB07, DSNDB04, and all user DBs
Db2 Directory and Data Sets
dsnzparm
CATALOG
catname.DSNDBx.DSNDB01.spacename.y0001.Annn
table space index space
SYSIBM.tablename
DSNLUX01
SYSUTILX SYSUTIL DSNLUX02
DBD01 DBD01 none
DSNLLX01
SYSLGRNX SYSLGRNX DSNLLX02
SCT02 SCT02 DSNSCT02
DSNSPT01
SPT01 SPT01 DSNSPT02
Not all the DIRECTORY Tables can be accessed by SQL
However, the contents can be determined by:
SYSUTIL -DISP UTIL command or DIAGNOSE utility
DBD01 -DISP DB command or DIAGNOSE utility
SYSLGRNG REPORT utility
SCT02 SQL on SYSPLAN in catalog
SPT01 SQL on SYSPACKAGE in catalog
DB2 Catalog - For All Users
System Database Application
Administrator Administrator Programmer
SQL
DB2
CATALOG
catname.DSNDBx.DSNDB06.spacename.y0001.Annn
table space SYSIBM.tablename index space
SYSDATABASE DSNDDH01,DSNDDX02
SYSDBAUT
SYSDBAUTH DSNADH01,DSNADX01
SYSCOLAUTH DSNACX01
SYSCOLUMNS DSNDCX01,DSNDCX02
SYSINDEXES DSNDXX01,DSNDXX02,
DSNDXX03,DSNDXX04
SYSINDEXPART DSNDRX01, DSNDRX02
SYSKEYS DSNDKX01
SYSDBASE
SYSFIELDS
SYSFOREIGNKEYS
-----
DSNDRH01
SYSRELS DSNDLX01,DSNDLX02
SYSSYNONYMS DSNDYX01
SYSTABAUTH DSNTAX01,DSNTAX02,
DSNTAX03,DSNTAX04
SYSTABLEPART DSNDPX01,DSNDPX02,DSNDPX03
SYSTABLES DSNDTX01,DSNDTX02,DSNDTX03
SYSTABLESPACE DSNDSX01
DB2 Catalog Maintenance
catname.DSNDBx.DSNDB06.spacename.y0001.Annn
Work!
DIS LOG
DIS BUFFERPOOL (BP0)
DIS DATABASE(*) SPACE(*)
Summary
• DB2 Architecture
• Described DB2 address space structure
• DB2 Objects
• Outlined DB2 Logging
• Described DB2 Catalog and Directory
• Described DSNZPARM
• Explained the DB2 Connection process
• Described DB2 self-descriptors: DSNZPARM, DSNDB01, and DSNDB06
Any Questions?
Thanks !!!