Automatic Data Optimization (ADO) and ILM

 

1. Introduction

Automatic Data Optimization (ADO) is an automated Information Lifecycle Management (ILM) engine natively built into Oracle Database. Originally introduced to eliminate manual database archiving workflows, ADO acts as an intelligent backend administrator. It monitors data activity patterns in real time and automatically compresses or shifts data across different storage tiers based on custom business rules.

1.1 ADO Policies

ADO policies can be applied at the Table / Partition (Segment) level or the Row level, and fall into three primary actions:

1. Data Compression Policies

These policies compress data to save space as it grows older and less active. Oracle supports multiple compression types:

•      Advanced Row Compression: Ideal for OLTP data that is still occasionally modified.

•      Hybrid Columnar Compression (HCC): Ideal for data warehousing or historical archives (e.g., QUERY HIGH or ARCHIVE HIGH).

2. Storage Tiering Policies

Instead of compressing the data within its current location, these policies automatically move segments to a different tablespace (e.g., from high-performance SSD storage to low-cost HDD storage).

3. Database In-Memory Policies

Introduced to manage the In-Memory column store. These control whether an object resides in memory based on usage.

•      SET INMEMORY (enable an object in memory).

•      MODIFY INMEMORY (change the in-memory compression level).

•      NO INMEMORY (evict an object from memory if it is no longer being actively queried).

1.2 Policy Evaluation Conditions

When defining an ADO policy, you specify a condition based on time and activity: [1]

•      Activity Types: NO ACCESS (neither read nor write), NO MODIFICATION (no writes/updates), or CREATION time.

•      Time frames: Specified in days, months, or years (e.g., AFTER 30 DAYS OF NO MODIFICATION).

•      Custom Rules: You can extend ADO by creating custom PL/SQL functions to evaluate complex business logic.

Policy Type

Typical Action

Typical Condition

Compression

Advanced Row Compression, HCC

NO ACCESS / NO MODIFICATION

Storage Tiering

Move segment to another tablespace

NO MODIFICATION, or custom function

Database In-Memory

SET / MODIFY / NO INMEMORY

CREATION, NO MODIFICATION, NO ACCESS

 

2. Enabling Heat Map

Implementing ADO is straightforward and is executed via declarative SQL syntax. ADO decisions are driven by Heat Map data, so Heat Map must be enabled on all instances of the cluster first.

ALTER SYSTEM SET HEAT_MAP = ON SCOPE=BOTH sid='*';

 

Title: Figure 1 - Description: Enabling Heat Map on all RAC instances

Figure 1: Enabling Heat Map on all RAC instances

Verify

Title: Figure 2 - Description: Verifying the Heat Map parameter

Figure 2: Verifying the Heat Map parameter

3. Segment-Level Compression Policy

3.1 Create a Table and Apply the ADO Policy at Segment Level

In this scenario, we will create an orders table. We will attach an ADO policy that automatically compresses the data using Advanced Row Compression after 1 day of no access.

-- 1. Create a standard relational table

CREATE TABLE orders (

  order_id      NUMBER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,

  customer_id   NUMBER NOT NULL,

  order_date    DATE DEFAULT SYSDATE,

  order_status  VARCHAR2(20),

  total_amount  NUMBER(10,2)

);

 

-- 2. Add an ADO Compression Policy to the table

ALTER TABLE orders

  ILM ADD POLICY

  ROW STORE COMPRESS ADVANCED

  SEGMENT AFTER 1 DAYS OF NO ACCESS;

 

Title: Figure 3 - Description: Creating the ORDERS table and adding the segment-level ILM policy

Figure 3: Creating the ORDERS table and adding the segment-level ILM policy

Title: Figure 4 - Description: Table and policy creation output (continued)

Figure 4: Table and policy creation output (continued)

Verify the Policy is Active

SELECT p.POLICY_NAME, p.POLICY_TYPE, p.TABLESPACE, p.ENABLED

FROM   USER_ILMPOLICIES p

JOIN   USER_ILMOBJECTS o ON p.POLICY_NAME = o.POLICY_NAME

WHERE  o.OBJECT_NAME = 'ORDERS';

 

Title: Figure 5 - Description: Active ILM policy on the ORDERS table

Figure 5: Active ILM policy on the ORDERS table

3.2 How ADO Works

•      Oracle Scheduler: The process begins during the Maintenance Window (usually overnight). The database scheduler triggers an internal evaluation job.

•      MMON (Manageability Monitor): This core background process coordinates ADO. MMON looks at the Heat Map data stored in the dictionary, evaluates your orders table policy, and checks if CURRENT_DATE - LAST_ACCESS_TIME > 1.

•      Job Slaves (Jnnn / Wnnn): If MMON decides the table qualifies for compression, it generates an ILM Task. The database then tasks background worker slaves to execute the actual ALTER TABLE ... COMPRESS operations online, preventing user disruption.

4. Row-Level Policy

4.1 How ADO Tracks Row-Level Access

While segment-level policies can track reads (like SELECT queries), row-level ADO policies only track modifications (DML) and row creation times.

•      The Reason: Tracking the exact time every single row is read by a SELECT statement would cause massive performance degradation.

•      Block-Level Cleanout: When a row is inserted or updated, Oracle logs this in the block header. When a block becomes full or undergoes standard maintenance, Oracle looks at the timestamps of the rows inside that specific block.

•      Evaluation Condition: If a row has not been modified (or was created) longer ago than your policy threshold, it becomes a candidate for row-level compression.

4.2 Syntax to Implement a Row-Level Policy

Here is how you would add a row-level compression policy to your orders table.

Delete the Segment-Level Policy

ALTER TABLE orders ILM DELETE POLICY P1;

 

Title: Figure 6 - Description: Deleting the existing segment-level policy

Figure 6: Deleting the existing segment-level policy

Apply the Row-Level Policy

ALTER TABLE orders ILM ADD POLICY ROW STORE COMPRESS ADVANCED ROW AFTER 1 DAYS OF NO MODIFICATION;

 

Title: Figure 7 - Description: Adding the row-level compression policy

Figure 7: Adding the row-level compression policy

Verify

Title: Figure 8 - Description: Row-level policy shown in the ILM views

Figure 8: Row-level policy shown in the ILM views

SET LINESIZE 150

COLUMN OBJECT_NAME FORMAT A20

COLUMN POLICY_NAME FORMAT A30

COLUMN POLICY_TYPE FORMAT A20

COLUMN ENABLED     FORMAT A10

 

SELECT o.OBJECT_NAME, o.POLICY_NAME, p.POLICY_TYPE, p.ENABLED

FROM   USER_ILMOBJECTS o

JOIN   USER_ILMPOLICIES p ON o.POLICY_NAME = p.POLICY_NAME

WHERE  o.OBJECT_NAME = 'ORDERS';

 

Title: Figure 9 - Description: Formatted verification query output

Figure 9: Formatted verification query output

5. Storage Tiering Policies

In this scenario, we will automate data movement across three distinct storage tiers based on data age and access frequency, combining tiering with compression to maximize cost savings.

Tier 1: Ultra-fast NVMe storage for recent, high-velocity transactions

CREATE TABLESPACE hot DATAFILE '+NVMe' SIZE 10G;   -- Tablespace created in the NVMe disk group

 

Tier 2: Standard HDD storage for operational data older than 90 days

CREATE TABLESPACE warm DATAFILE '+HDD' SIZE 15G;   -- Tablespace created in the SSD disk group

 

Drop the Existing ILM Policy

ALTER TABLE orders ILM DELETE POLICY P21;

 

Title: Figure 10 - Description: Removing the previous ILM policy

Figure 10: Removing the previous ILM policy

Policy 1: Compress warm data within the hot tier after 30 days of no changes

ALTER TABLE orders ILM ADD POLICY ROW STORE COMPRESS ADVANCED SEGMENT AFTER 30 DAYS OF NO MODIFICATION;

 

Title: Figure 11 - Description: Policy 1: segment compression after 30 days of no modification

Figure 11: Policy 1: segment compression after 30 days of no modification

Policy 2: Down-tier data to standard HDD after 90 days of no changes

This policy is implemented through a custom PL/SQL function.

Use Custom Function

CREATE OR REPLACE FUNCTION check_90_days_no_mod(p_object_id IN NUMBER)

RETURN BOOLEAN

AS

  v_days_since_mod NUMBER;

BEGIN

  SELECT (SYSDATE - h.segment_write_time)

  INTO   v_days_since_mod

  FROM   user_heat_map_segment h

  JOIN   user_objects o ON h.object_name = o.object_name

  WHERE  o.object_id = p_object_id;

 

  IF v_days_since_mod >= 90 THEN

    RETURN TRUE;

  ELSE

    RETURN FALSE;

  END IF;

EXCEPTION

  WHEN NO_DATA_FOUND THEN

    RETURN FALSE;

  WHEN OTHERS THEN

    RETURN FALSE;

END;

/

 

Title: Figure 12 - Description: Creating the custom function check_90_days_no_mod

Figure 12: Creating the custom function check_90_days_no_mod

ALTER TABLE orders ILM ADD POLICY TIER TO cold ON check_90_days_no_mod;

 

Title: Figure 13 - Description: Attaching the tiering policy with the custom function

Figure 13: Attaching the tiering policy with the custom function

Verify

SELECT policy_name, action_type, tier_tablespace, condition_type, condition_days, custom_function

FROM   user_ilmdatamovementpolicies;

 

Title: Figure 14 - Description: Data-movement policies registered for the ORDERS table

Figure 14: Data-movement policies registered for the ORDERS table

6. Database In-Memory Policies

6.1 SET INMEMORY Policy

This policy is used to populate an object into the IM column store. It is useful when a segment is created and undergoes heavy DML activity initially, but you want to wait until that activity subsides before loading it into memory to get the best performance for subsequent queries.

ALTER TABLE orders ILM ADD POLICY SET INMEMORY MEMCOMPRESS FOR QUERY HIGH PRIORITY HIGH SEGMENT AFTER 30 DAYS OF CREATION;

 

Title: Figure 15 - Description: SET INMEMORY policy added to the ORDERS table

Figure 15: SET INMEMORY policy added to the ORDERS table

•      MEMCOMPRESS FOR QUERY HIGH: Specifies the compression level for the in-memory data. This is a good balance between compression and query performance.

•      PRIORITY HIGH: Sets a high priority for populating this segment into the IM column store.

•      SEGMENT: Specifies that the policy applies to the entire segment (table or partition).

•      AFTER 30 DAYS OF CREATION: The policy will be evaluated after 30 days from the object’s creation date.

6.2 MODIFY INMEMORY Policy (Recompression Policy)

This policy is used to change the compression level of an object that is already in the IM column store. A common use case is to start with a lower compression level that is faster for DML, and then, after modifications have ceased, automatically switch to a higher compression level that is optimized for queries.

ALTER TABLE orders ILM ADD POLICY MODIFY INMEMORY MEMCOMPRESS FOR CAPACITY HIGH SEGMENT AFTER 90 DAYS OF NO MODIFICATION;

 

Title: Figure 16 - Description: MODIFY INMEMORY (recompression) policy

Figure 16: MODIFY INMEMORY (recompression) policy

•      MEMCOMPRESS FOR CAPACITY HIGH: This changes the compression to a higher level, which saves more memory space but may have a slight performance trade-off for queries. This is ideal for data that is no longer being actively modified.

•      AFTER 90 DAYS OF NO MODIFICATION: The policy will be evaluated when the segment has not been modified for 90 days.

6.3 NO INMEMORY Policy (Eviction Policy)

This policy is used to evict an object from the IM column store and remove its INMEMORY attribute. It is useful for optimizing the limited memory resources by removing segments that are no longer being actively queried, preventing them from occupying valuable space.

ALTER TABLE orders ILM ADD POLICY NO INMEMORY SEGMENT AFTER 180 DAYS OF NO ACCESS;

 

Title: Figure 17 - Description: NO INMEMORY (eviction) policy

Figure 17: NO INMEMORY (eviction) policy

6.4 Verify

SELECT p.policy_name, p.policy_type, p.enabled, p.deleted

FROM   user_ilmpolicies p

JOIN   user_ilmobjects o ON p.policy_name = o.policy_name

WHERE  o.object_name = 'ORDERS';

 

Title: Figure 18 - Description: All ILM policies attached to the ORDERS table

Figure 18: All ILM policies attached to the ORDERS table

SELECT policy_name, action_type, scope, condition_type, condition_days, custom_function

FROM   user_ilmdatamovementpolicies

WHERE  policy_name IN (

  SELECT p.policy_name

  FROM   user_ilmpolicies p

  JOIN   user_ilmobjects o ON p.policy_name = o.policy_name

  WHERE  o.object_name = 'ORDERS'

);

 

Title: Figure 19 - Description: Policy conditions and scope for the ORDERS table

Figure 19: Policy conditions and scope for the ORDERS table

References

[1]  Oracle White Paper – Automatic Data Optimization: oracle.com/assets/automatic-data-optimization-wp-12c-1896120.pdf

Comments