TWiki > Deployment Web > DeploymentAdminstering > ConfiguringAndTuningDBTablespaces
Revision 3 - 2025-03-12 - 18:05:15 - RichardWatts

Restructuring Data in Relational Databases: Moving Tables to Optimize Performance

Authors: RichardWatts
Build basis: All Jazz-based products, 7.0.2, onwards.

Summary

This article explores the importance of restructuring data in relational databases by moving tables and supporting files from default tablespaces to alternative ones. Using case studies for Db2 and Oracle, we demonstrate how to address specific challenges, such as improving backup performance and supporting very large table growth.

Introduction

Relational databases often rely on tablespaces to manage data storage efficiently. Over time, database performance and capacity requirements may necessitate restructuring, such as moving tables to new tablespaces. This process can improve system performance, optimize storage, and support scalability. This article presents two real-world scenarios where moving tables in Db2 and Oracle provided critical solutions.

What Are Tablespaces?

Tablespaces are logical storage units in relational databases that organize and separate data. By grouping tables, indexes, and large objects, tablespaces allow administrators to manage physical storage resources effectively.

Key Features:

  • Logical Organization: Helps isolate data for performance tuning.
  • Scalability: Allows for controlled expansion of storage.
  • Flexibility: Optimizes specific workloads through dedicated resources.

Why Restructure Your Data?

Restructuring data is essential to address several common database challenges:

  • Improved Performance: Optimize backup and recovery operations.
  • Storage Limitations: Resolve tablespace size restrictions.
  • Scalability: Support future growth without compromising database stability.

Case Study One: Speed Up Backup Times in Db2

A large Db2 table in the default tablespace significantly slows down backup performance. Moving the table to a new tablespace enhances backup speed and system performance.

Steps to Move a Table to a New Tablespace in Db2:

  1. Create a New Tablespace: CREATE TABLESPACE NEW_TS MANAGED BY DATABASE USING (FILE '/path/to/new/ts/file' 10000) EXTENTSIZE 32 PREFETCHSIZE 32 BUFFERPOOL BP32K;
  2. Export the Table Data: (bash script) db2 EXPORT TO table_data.ixf OF IXF MESSAGES msg.txt SELECT * FROM large_table;
  3. Drop the Original Table: DROP TABLE large_table;
  4. Recreate the Table in the New Tablespace: CREATE TABLE large_table (column1 INT, column2 VARCHAR(255), ...) IN NEW_TS;
  5. Import Data into the New Table: (bash script) db2 IMPORT FROM table_data.ixf OF IXF MESSAGES msg.txt INSERT INTO large_table;
  6. Rebuild Indexes: Recreate any necessary indexes on the table.
  7. Validate and Test: Perform tests to ensure table integrity and improved backup performance.

Case Study Two: Address Oracle Tablespace Limitations Through Restructuring

An Oracle table in the default tablespace has grown beyond 30TB and requires migration to a new tablespace with support for very large tables (128TB).

Steps to Move a Table to a New Tablespace in Oracle:

  1. Create a New Tablespace: CREATE BIGFILE TABLESPACE very_large_ts DATAFILE '/path/to/very_large_ts.dbf' SIZE 1T AUTOEXTEND ON NEXT 1G MAXSIZE 128T EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;
  2. Move the Table to the New Tablespace: ALTER TABLE large_table MOVE TABLESPACE very_large_ts;
  3. Rebuild Indexes: ALTER INDEX index_name REBUILD TABLESPACE very_large_ts;
  4. Update Statistics: EXEC DBMS_STATS.GATHER_TABLE_STATS('schema_name', 'large_table');
  5. Validate and Test: Test the application to ensure all dependent queries and operations function as expected. Verify that the new tablespace supports the required growth.

Closing

Restructuring tablespaces in relational databases is crucial for maintaining optimal performance and scalability. By following the steps outlined in the Db2 and Oracle case studies, administrators can address challenges such as improving backup performance and accommodating large tables.

Resources

Related topics: Deployment web home, Deployment web home

External links:

Additional contributors:

Edit | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r3 < r2 < r1 | More topic actions
This site is powered by the TWiki collaboration platformCopyright © by IBM and non-IBM contributing authors. All material on this collaboration platform is the property of the contributing authors.
Contributions are governed by our Terms of Use. Please read the following disclaimer.
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.