Bufferpools and Tablespaces
- Page - Basic unit of storage in Db2. There are 4 page sizes. 4K, 8K, 16K, 32K
- Extent - Set of Pages
- Container - Set of Extents
- Tablespaces - These are logical objects
- Basing on space management
- SMS - System Managed Space - Space in this will be managed by OS - Containers are directory
- DMS - Database Managed Space - Space in this will be managed by Db2 - Containers are files
- Automatic storage tablespace - could either SMS or DMS
- SMS - for storing temporary data
- DMS - for storing permanent data
- Basing on type of data they store
- Regular - to store tradition data
- Large - to store tradition data + non traditional data - most frequently used and IBM recommended
- User temporary - to store user temporary tables - DGTT - SESSION schema
- System temporary - to store data for operations like sorting (Select query order by clause)
db2 "create <tbsp_data_type> tablespace <tablespacename>
PAGESIZE n K
MANAGED BY <space management>
BUFFERPOOL <bufferpoolname>
NO FILE SYSTEM CACHING
DROPPED TABLE RECOVERY ON"
PAGESIZE n K
MANAGED BY <space management>
BUFFERPOOL <bufferpoolname>
NO FILE SYSTEM CACHING
DROPPED TABLE RECOVERY ON"
To create a SMS tablespace - we will not specify size attributes for SMS tbps because this is managed by OS
db2 "create tablespace <tablespacename>
PAGESIZE n K
MANAGED BY SYSTEM USING ('containerstring1','containerstring2',...)
BUFFERPOOL <bufferpoolname>
NO FILE SYSTEM CACHING
DROPPED TABLE RECOVERY ON"
To create a DMS tablespace
db2 "create tablespace <tablespacename>
PAGESIZE n K
MANAGED BY DATABASE USING (FILE 'containerstring1' no_of_pages,
FILE 'containerstring2' no_of_pages,...)
BUFFERPOOL <bufferpoolname>
NO FILE SYSTEM CACHING
DROPPED TABLE RECOVERY ON"
MANAGED BY SYSTEM USING ('containerstring1','containerstring2',...)
BUFFERPOOL <bufferpoolname>
NO FILE SYSTEM CACHING
DROPPED TABLE RECOVERY ON"
To create a DMS tablespace
db2 "create tablespace <tablespacename>
PAGESIZE n K
MANAGED BY DATABASE USING (FILE 'containerstring1' no_of_pages,
FILE 'containerstring2' no_of_pages,...)
BUFFERPOOL <bufferpoolname>
NO FILE SYSTEM CACHING
DROPPED TABLE RECOVERY ON"
Since space in DMS is limited, we will create tablespace as Autoextend/Autoresize
db2 "create tablespace <tablespacename>
PAGESIZE n K
MANAGED BY DATABASE USING (FILE 'containerstring1' no_of_pages,
FILE 'containerstring2' no_of_pages,...)
AUTORESIZE YES INITIALSIZE x <K|M|G> INCREASESIZE x <K|M|G> MAXSIZE <x <K|M|G> or NONE>
BUFFERPOOL <bufferpoolname>
NO FILE SYSTEM CACHING
DROPPED TABLE RECOVERY ON"
To address the limitations of both these type of tablespaces, we will create Automatic storage tablespaces
db2 "create tablespace <tablespacename>
PAGESIZE n K
MANAGED BY AUTOMATIC STORAGE
AUTORESIZE YES INITIALSIZE x <K|M|G> INCREASESIZE x <K|M|G> MAXSIZE <x <K|M|G> or NONE>
BUFFERPOOL <bufferpoolname>
NO FILE SYSTEM CACHING
DROPPED TABLE RECOVERY ON"
db2 "create tablespace <tablespacename>
PAGESIZE n K
MANAGED BY AUTOMATIC STORAGE
AUTORESIZE YES INITIALSIZE x <K|M|G> INCREASESIZE x <K|M|G> MAXSIZE <x <K|M|G> or NONE>
BUFFERPOOL <bufferpoolname>
NO FILE SYSTEM CACHING
DROPPED TABLE RECOVERY ON"
No comments:
Post a Comment