System Objects
DB2 Catalog -
The DB2 Catalog is a collection of tables that store metadata about the database. Metadata includes information about database objects, such as tables, indexes, views, columns, and users. Basically, the catalog tracks the structure and configuration of the entire DB2 database system.
It helps DBAs (Database Administrators) understand and manage the database by providing information about tables, columns, indexes, etc.
Usage: The catalog is automatically updated whenever objects like tables or indexes are created or changed.
DB2 Directory -
The DB2 Directory is a set of internal system tables that store important information required by the DB2 database to operate. Unlike the catalog, the directory stores operational data that helps the system work efficiently. The directory is critical to the database engine and is maintained automatically by DB2.
What it Contains:
- Information about packages (compiled SQL statements).
- Information about databases, table spaces, and buffer pools.
- System configurations required for performance tuning.
Usage: It helps DB2 manage SQL execution plans and optimizes access paths. The system accesses the DB2 Directory in the background; users typically don’t query it directly.
Buffer Pool -
A Buffer Pool is a portion of memory where frequently accessed data is temporarily stored. This speeds up data retrieval and reduces the load on the storage disk. Instead of reading from the disk every time data is needed, the database fetches it from the buffer pool, which is much faster.
Example: If customer table data is frequently queried, it will be stored in the buffer pool to allow quick access.
Benefit: Reduces disk I/O operations and speeds up the database.
DB2 Logs -
DB2 uses logs to keep track of all database changes to ensure data integrity and recovery. These logs store records of every change, such as inserts, updates, and deletes.
- Active Logs - These logs store current transactions that are actively being processed or have been recently committed. If there is a system failure, the active logs are used to recover uncommitted transactions.
- Archive Logs - These logs are older logs of certain duration might be month or years back logs. These are used for long-term storage and disaster recovery.
Usage:
- Active logs ensure the system can recover from crashes by replaying recent transactions.
- Archive logs are used for point-in-time recovery to restore the database to a specific moment.
Work File Database -
The Work File Database is a special database that stores temporary data during query processing. When a query is too large to be processed in memory or requires complex sorting or joins, DB2 uses the Work File Database to hold intermediate results temporarily.
Example: If we run a query that involves sorting thousands of records, DB2 may temporarily use the work file database to store partial results.
Usage:
- It improves performance for complex operations, such as sorting and joins.
- The work file database is necessary for handling large queries that cannot fit in memory.