Post Contents

Oracle 19c Using Table and Row Compression

Oracle 19c Using Table and Row Compression

Managing segments in Oracle 19c is crucial for database administrators to ensure optimal performance and efficient storage use. In this tutorial, we will explore various aspects of Table Compression and Row Compression, focusing on how to effectively implement these techniques to enhance Data Compression and Storage Optimization. Understanding these compression methods is essential for maintaining a well-organized and high-performing database system.

 

Table Compression

Table Compression is a technique used to reduce the amount of storage space required by tables. It works by compressing the data within the table, which can lead to significant savings in storage space and improved performance.

Basic Table Compression: This is a free data compression capability included with the Enterprise Edition. Basic Compression compresses data that is loaded using bulk load operations (direct path), but does not compress data added or updated through conventional DML operations (INSERT or UPDATE). To compress data added or updated over time, you need to re-compress the table or partition.

Usage: Basic Table Compression is not intended for OLTP applications. It is best suited for data warehouse applications where data is loaded using bulk load operations and is rarely modified.

-- Creating a table with basic compression
CREATE TABLE employees (
employee_id NUMBER PRIMARY KEY,
first_name VARCHAR2(50),
last_name VARCHAR2(50),
email VARCHAR2(100),
hire_date DATE
) COMPRESS BASIC;

-- Altering an existing table to enable basic compression
ALTER TABLE employees COMPRESS BASIC;

 

Table Compression – Row Compression

Row Compression is another method to reduce storage space by compressing individual rows of data within a table. This technique can be particularly effective for tables with large amounts of repetitive data.

Advanced Row Compression: This feature of Advanced Compression maintains data compression during all types of data manipulation operations, including conventional DML such as INSERT and UPDATE. It uses a compression algorithm specifically designed to eliminate duplicate values within a database block, even across multiple columns.

Usage: Advanced Row Compression is suitable for both OLTP and Data Warehouse applications.

-- Creating a table with advanced row compression
CREATE TABLE sales (
sale_id NUMBER PRIMARY KEY,
sale_date DATE,
amount NUMBER
) COMPRESS FOR OLTP;

-- Altering an existing table to enable advanced row compression
ALTER TABLE sales COMPRESS FOR OLTP;

 

📢 You might also like: Oracle 19c Understanding Block Space Management (Category: Oracle Database Admin)

Table Compression – Hybrid Columnar Compression

Hybrid Columnar Compression (HCC) utilizes a combination of both row and columnar methods for storing data. This hybrid approach achieves the compression benefits of columnar storage while avoiding the performance shortfalls of a pure columnar format. Data must be loaded using bulk loading techniques to maximize storage savings with HCC.

Usage: HCC is best suited for data warehouse applications where data is loaded using bulk load operations and is rarely modified. While HCC compressed data can be modified using conventional DML operations, it is best for applications with limited DML operations.

-- Example of creating a table with hybrid columnar compression
CREATE TABLE inventory (
item_id NUMBER PRIMARY KEY,
item_name VARCHAR2(100),
quantity NUMBER
) COMPRESS FOR QUERY HIGH;

 

Monitoring and Managing Compression

Effective Data Compression involves continuous monitoring and management. Oracle 19c provides various tools and views, such as DBA_TABLES and DBA_SEGMENTS, to monitor the effectiveness of Table and Row Compression.

To check the compression status of a table, you can use the following query:

-- Checking the compression status of a table
SELECT table_name, compression, compress_for
FROM dba_tables
WHERE table_name = 'EMPLOYEES';

 

Best Practices for Compression

To achieve optimal results with Table Compression and Row Compression, consider the following best practices:

  • Choose the Right Compression Method: Select the appropriate compression method based on your data and usage patterns.
  • Regularly Monitor Compression: Use Oracle’s monitoring tools to regularly check the effectiveness of your compression strategies.
  • Test Compression Impact: Before applying compression to production tables, test its impact on performance and storage in a non-production environment.

 

Conclusion

In conclusion, Table Compression and Row Compression in Oracle 19c are powerful techniques for Data Compression and Storage Optimization. By understanding and implementing these methods, database administrators can achieve significant storage savings and improved performance. Regular monitoring and following best practices are key to maximizing the benefits of compression in Oracle 19c.

See more on Oracle’s website!

Be Oracle Database Certified Professional, this world is full of opportunities for qualified DBAs!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top