Tablespaces - (DB2 Bufferpool)
In DB2, a bufferpool is an area of memory where frequently accessed database pages are stored for quick retrieval. A tablespace is a logical storage area that holds one or more tables, indexes, and other database objects. In this page, we will cover how to create bufferpools and tablespaces in DB2.
Syntax
Creating a bufferpool
CREATE BUFFERPOOL bufferpool_name SIZE bufferpool_size;
Here, bufferpool_name
is the name of the bufferpool, and bufferpool_size
is the size of the bufferpool in pages.
Creating a tablespace
CREATE TABLESPACE tablespace_name
PAGESIZE page_size
MANAGED BY system_or_database_managed
BUFFERPOOL bufferpool_name
OVERHEAD overhead_size;
Here, tablespace_name
is the name of the tablespace, page_size
is the size of the pages used by the tablespace, system_or_database_managed
indicates whether the tablespace is system or database managed, bufferpool_name
is the name of the bufferpool to be used by the tablespace, and overhead_size
is the amount of extra space required by the tablespace.
Example
Creating a bufferpool
CREATE BUFFERPOOL BP01 SIZE 2000;
Here, we create a bufferpool with the name BP01
and a size of 2000 pages.
Creating a tablespace
CREATE TABLESPACE TSPACE01
PAGESIZE 4K
MANAGED BY SYSTEM
BUFFERPOOL BP01
OVERHEAD 10%;
Here, we create a tablespace with the name TSPACE01
that uses a page size of 4K, is system-managed, and uses the bufferpool BP01
. We also set the overhead of the tablespace to 10%.
Output
The output from creating a bufferpool or tablespace is a message indicating the successful creation of the object, warnings (if any), and any error messages that may have occurred.
Explanation
A bufferpool is an area of memory where frequently accessed database pages are stored for quick retrieval. When a page is requested, the bufferpool is searched first to see if the page is already in memory. If it is not, the page is read from disk into memory.
A tablespace is a logical storage area that holds one or more tables, indexes, and other database objects. By default, a newly created tablespace is database-managed, which means that the database system automatically manages the space allocation and storage of tablespace pages. However, you can also opt to have a tablespace managed by the system, which gives you more control over the storage and management of data.
Use
Creating bufferpools and tablespaces in DB2 is a necessary step in managing database performance and ensuring the reliability and availability of data. By configuring bufferpools and tablespaces appropriately, you can optimize database performance, improve system response times, and prevent data loss.
Important Points
- A bufferpool is an area of memory where frequently accessed database pages are stored for quick retrieval.
- A tablespace is a logical storage area that holds one or more tables, indexes, and other database objects.
- Newly created tablespaces are database-managed by default, but can also be system-managed.
- Creating bufferpools and tablespaces is an important step in managing database performance and ensuring data reliability and availability.
Summary
In summary, bufferpools and tablespaces are important components for managing database performance and ensuring data reliability and availability in DB2. Bufferpools store frequently accessed database pages in memory for quick retrieval, while tablespaces hold one or more tables, indexes, and other database objects. Creating bufferpools and tablespaces must be done with care to optimize performance and prevent data loss.