DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Data Architectures in the AI Era: Key Strategies and Insights
  • Data Pipeline Techniques in Action
  • MaxLinear Empowers High-Speed Connectivity and Data Acceleration Solutions for Next-Gen Computing
  • Revisiting Observability: A Deep Dive Into the State of Monitoring, Costs, and Data Ownership in Today’s Market

Trending

  • 5 Best Node.js Practices to Develop Scalable and Robust Applications
  • Solid Testing Strategies for Salesforce Releases
  • How to Build Scalable Mobile Apps With React Native: A Step-by-Step Guide
  • The Transformative Power of Artificial Intelligence in Cloud Security
  1. DZone
  2. Data Engineering
  3. Data
  4. Optimizing Data Storage With Hybrid Partitioned Tables in Oracle 19c

Optimizing Data Storage With Hybrid Partitioned Tables in Oracle 19c

Learn how to implement Hybrid Partitioned Tables (HPT) to streamline data management, boost query performance, and cut storage costs.

By 
arvind toorpu user avatar
arvind toorpu
DZone Core CORE ·
Apr. 08, 25 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
2.8K Views

Join the DZone community and get the full member experience.

Join For Free

Effective management of large datasets is paramount for both performance and cost optimization. Oracle 19c introduces Hybrid Partitioned Tables (HPT), a feature that allows you to distribute table partitions across multiple storage tiers — from high-performance on-premises systems to cost-effective cloud-based object storage. This approach enables organizations to store frequently accessed “hot” data locally for faster processing while archiving less-active “cold” data in the cloud.

Learn how to implement Hybrid Partitioned Tables (HPT) to streamline data management, boost query performance, and cut storage costs.


What Are Hybrid Partitioned Tables?

Hybrid Partitioned Tables enable you to:

  • Store hot data (frequently accessed) in local database storage.
  • Store cold data (infrequently accessed) in external object storage, such as Oracle Cloud Infrastructure (OCI) Object Storage.
  • Query both internal and external partitions seamlessly without application changes.

Hybrid partition table

This approach is ideal for organizations looking to optimize storage costs while maintaining high performance for critical data.


Step-by-Step Guide to Implementing Hybrid Partitioned Tables

Step 1: Prerequisites

  • Oracle Database 19c installed.
  • Access to Oracle Cloud Infrastructure (OCI) Object Storage (or any compatible external storage).
  • A bucket was created in OCI Object Storage to store external partitions.

Dataflow-hybrid partition

Dataflow-hybrid partition

Step 2: Create a Hybrid Partitioned Table

Let’s create a hybrid partitioned table to store sales data. Recent sales data will be stored locally, while older data will be stored in OCI Object Storage.

SQL
 
-- Create a Hybrid Partitioned Table
CREATE TABLE sales (
    sale_id   NUMBER,
    sale_date DATE,
    amount    NUMBER
)
PARTITION BY RANGE (sale_date) (
    PARTITION p2023_q1 VALUES LESS THAN (TO_DATE('2023-04-01', 'YYYY-MM-DD')),
    PARTITION p2023_q2 VALUES LESS THAN (TO_DATE('2023-07-01', 'YYYY-MM-DD')),
    PARTITION p2023_q3 VALUES LESS THAN (TO_DATE('2023-10-01', 'YYYY-MM-DD')),
    PARTITION p2023_q4 VALUES LESS THAN (TO_DATE('2024-01-01', 'YYYY-MM-DD'))
)
HYBRID (
    PARTITION p2023_q1 EXTERNAL LOCATION (
        'https://objectstorage.us-ashburn-1.oraclecloud.com/n/namespace/b/bucket/o/p2023_q1.csv'
    ),
    PARTITION p2023_q2 EXTERNAL LOCATION (
        'https://objectstorage.us-ashburn-1.oraclecloud.com/n/namespace/b/bucket/o/p2023_q2.csv'
    )
);


Step 3: Load Data into Partitions

  • Load recent data into internal partitions:

    SQL
     
    INSERT INTO sales VALUES (1, TO_DATE('2023-01-15', 'YYYY-MM-DD'), 1000);
    INSERT INTO sales VALUES (2, TO_DATE('2023-06-20', 'YYYY-MM-DD'), 1500);
  • Load older data into external partitions (upload CSV files to OCI Object Storage):

    SQL
     
    -- Example CSV content for p2023_q1.csv:
    -- 3,2023-02-10,2000
    -- 4,2023-03-25,2500

Step 4: Query the Hybrid Partitioned Table

Query the table to retrieve data from both internal and external partitions:

SQL
 
SELECT * 
FROM sales
WHERE sale_date BETWEEN TO_DATE('2023-01-01', 'YYYY-MM-DD') 
                    AND TO_DATE('2023-12-31', 'YYYY-MM-DD');


Adding and Dropping Partitions

Adding a Partition

Use the statement to add a new partition to the hybrid partitioned table. For example, to add a partition for Q1 2024:

SQL
 
ALTER TABLE sales 
ADD PARTITION p2024_q1 
VALUES LESS THAN (TO_DATE('2024-04-01', 'YYYY-MM-DD'));


Dropping a Partition

To drop an existing partition, use the ALTER TABLE ... DROP PARTITION statement. For example, to drop the Q1 2023 partition:

SQL
 
ALTER TABLE sales 
DROP PARTITION p2023_q1;


Adding an External Partition

To add an external partition, specify the external location:

SQL
 
ALTER TABLE sales 
ADD PARTITION p2023_q1 
VALUES LESS THAN (TO_DATE('2023-04-01', 'YYYY-MM-DD')) 
EXTERNAL 
DEFAULT DIRECTORY tmp_dir 
LOCATION ('p2023_q1.csv');


Dropping an External Partition

Dropping an external partition is similar to dropping an internal partition:

SQL
 
ALTER TABLE sales 
DROP PARTITION p2023_q1;


Simulation Scenario: Performance and Cost Benefits

Scenario Setup

  • Table Size: 1 million rows (500,000 in internal storage, 500,000 in external storage).
  • Query Pattern:
    • 80% of queries access recent data (internal partitions).
    • 20% of queries access historical data (external partitions).

Performance Metrics

Metric Internal Partitions External Partitions
Query Response Time (Avg) 0.5 seconds 2.5 seconds
Storage Cost (per GB/month) $0.10 (on-premises) $0.02 (cloud)

Cost Savings

  • Storing 500,000 rows in external storage reduces monthly storage costs by 80% compared to on-premises storage.


Restrictions on Hybrid Partitioned Tables

While Hybrid Partitioned Tables offer significant flexibility, there are some restrictions to be aware of:

  1. Partitioning Types:
    1. Only RANGE and LIST partitioning are supported.
    2. REFERENCE and SYSTEM partitioning are not supported.
  2. DML Operations:
    1. DML operations (INSERT, UPDATE, DELETE) are allowed only on internal partitions.
    2. Attempting to modify external partitions results in an error.
SQL
 
INSERT INTO sales 
VALUES ('GBR', 9999, 'X', 'X');

-- ERROR: ORA-14466: Data in a read-only partition or subpartition cannot be modified.


  1. External Partition Limitations:
    1. External partitions are read-only.
    2. Data in external partitions must be stored in flat files (e.g., CSV) in object storage.
  2. Other Restrictions:
    1. Certain operations, such as splitting or merging partitions, may have limitations depending on the partitioning type and storage tier.

Best Practices for Hybrid Partitioned Tables

  1. Data Lifecycle Management:
    1. Use Oracle’s Automatic Data Optimization (ADO) to automate the movement of data between storage tiers based on access patterns.
  2. Partition Design:
    1. Choose a partitioning strategy (e.g., range, list) that aligns with your data access patterns.
  3. Monitoring:
    1. Regularly monitor query performance and storage costs using Oracle’s performance views (e.g., DBA_HYBRID_PART_TABLES).

Conclusion

Hybrid Partitioned Tables in Oracle 19c provide a flexible, cost-effective solution for managing large datasets. Organizations can achieve significant cost savings without compromising performance by storing hot data locally and cold data in external storage. Follow the steps in this article to implement HPT and optimize your data storage strategy.

Data storage Data (computing) Partition (database)

Opinions expressed by DZone contributors are their own.

Related

  • Data Architectures in the AI Era: Key Strategies and Insights
  • Data Pipeline Techniques in Action
  • MaxLinear Empowers High-Speed Connectivity and Data Acceleration Solutions for Next-Gen Computing
  • Revisiting Observability: A Deep Dive Into the State of Monitoring, Costs, and Data Ownership in Today’s Market

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • [email protected]

Let's be friends: