Presentation is loading. Please wait.

Presentation is loading. Please wait.

REMINDER Check in on the COLLABORATE mobile app Something Old, Something New: Leveraging Oracle 12cs Information Lifecycle Management (ILM) Features for.

Similar presentations


Presentation on theme: "REMINDER Check in on the COLLABORATE mobile app Something Old, Something New: Leveraging Oracle 12cs Information Lifecycle Management (ILM) Features for."— Presentation transcript:

1 REMINDER Check in on the COLLABORATE mobile app Something Old, Something New: Leveraging Oracle 12cs Information Lifecycle Management (ILM) Features for Improved Database Performance Session #187 Jim Czuprynski Zero Defect Computing, Inc. April 9, 2014

2 My Credentials 30+ years of database-centric IT experience Oracle DBA since 2001 Oracle 9i, 10g, 11g OCP and Oracle ACE Director > 100 articles on databasejournal.com and ioug.org Teach core Oracle DBA courses (Grid + RAC, Exadata, Performance Tuning, Data Guard) Regular speaker at Oracle OpenWorld, IOUG COLLABORATE, OUG Norway, and Hotsos Oracle-centric blog (Generally, It Depends)

3 Our Agenda The Persistence of Data Through Time Information Lifecycle Management (ILM) In-Database Archiving (IDA) Concepts Temporal Validity (TV) Concepts Temporal History: Old Feature, New Name Leveraging ILM ADO Features Q+A

4 The Persistence of Data Through Time Data needs to be retained for inordinately long periods of time Data mining / warehousing / trend analysis Regulatory and legal requirements Once data has been purged … its often needed again (usually immediately) Therefore, data purging doesnt happen nearly as often as it should Handling schema changes after archiving is a nightmare … … so, what if we never purged data at all?

5 Information Lifecycle Management (ILM) ILM encompasses three key feature sets: In-Database Archiving (IDA) stores active and inactive data within same table Temporal Validity (TV) stores past, current, and future data within same table Automatic Data Optimization (ADO) tiers data according to its age and usage as well as how much space it consumes

6 In-Database Archiving (IDA): A Cloaking Device

7 In-Database Archiving (IDA) Avoids unnecessary deletion of rows when they no longer contain valid data Activated via new ROW ARCHIVAL attribute of data segment During initial INSERT, each rows state is set to active by placing a zero (0) in the ORA_ARCHIVE_STATE hidden column A row can be marked as inactive by setting ORA_ARCHIVE_STATE to any non-zero value Unless the ORA_ ARCHIVE_STATE column is mentioned in query, a rows IDA status is invisible Inactive rows can be compressed via ILM

8 Activating IDA CREATE table oe.currency_conversions ( currency_from VARCHAR2(3) NOT NULL,currency_to VARCHAR2(3) NOT NULL,effect_dtm TIMESTAMP NOT NULL,conversion_fctr NUMBER(10,6) DEFAULT 0 ) TABLESPACE example; ALTER TABLE oe.currency_conversions ROW ARCHIVAL; Activates In- Database Archiving for an existing table CREATE table oe.currency_conversions ( currency_from VARCHAR2(3) NOT NULL,currency_to VARCHAR2(3) NOT NULL,effect_dtm TIMESTAMP NOT NULL,conversion_fctr NUMBER(10,6) DEFAULT 0 ) ROW ARCHIVAL TABLESPACE example; Activates In- Database Archiving immediately upon table creation

9 COL column_name FORMAT A30 HEADING "Column Name" COL segment_column_id FORMAT 9999 HEADING "Seg|Col|#" COL internal_column_id FORMAT 9999 HEADING "Int|Col|#" COL hidden_column FORMAT A08 HEADING "Hidden?" COL virtual_column FORMAT A08 HEADING "Virtual?" COL user_generated FORMAT A08 HEADING "User|Gen'd?" TTITLE "Metadata for Table OE.CURRENCY_CONVERSIONS|(from DBA_TAB_COLS)" SELECT column_name,segment_column_id,internal_column_id,hidden_column,virtual_column,user_generated FROM dba_tab_cols WHERE owner = 'OE' AND table_name = 'CURRCONV_PARTED' ORDER BY internal_column_id; TTITLE OFF Viewing IDA Metadata Metadata for Table OE.CURRENCY_CONVERSIONS (from DBA_TAB_COLS) Seg Int Col Col User Column Name # # Hidden? Virtual? Gen'd? CURRENCY_FROM 1 1 NO NO YES CURRENCY_TO 2 2 NO NO YES EFFECT_DTM 3 3 NO NO YES CONVERSION_FCTR 4 4 NO NO YES SYS_NC00005$ 5 5 YES NO NO ORA_ARCHIVE_STATE 6 6 YES NO NO Note the addition of two new hidden columns exclusively for IDA

10 Populating IDA Test Data DECLARE ctr NUMBER := 0; curfr CHAR(3); curto CHAR(3); effdt DATE; BEGIN FOR ctr IN LOOP effdt := (TO_DATE('12/31/2015','mm/dd/yyyy') - (ctr/10)); INSERT INTO oe.currconv_parted VALUES( DECODE(MOD(ctr, 6), 0,'USD', 1,'JPY', 2,'EUR', 3,'AUD', 4,'CHF', 5, 'GBP'),DECODE(MOD(ctr,36), 0,'JPY', 1,'EUR', 2,'AUD', 3,'CHF', 4,'GBP', 5,'CDN', 6,'EUR', 7,'AUD', 8,'CHF', 9,'GBP', 10,'CDN', 11,'USD', 12,'AUD', 13,'CHF', 14,'GBP', 15,'CDN', 16,'USD', 17,'JPY', 18,'CHF', 19,'GBP', 20,'CDN', 21,'USD', 22,'JPY', 23,'EUR', 24,'GBP', 25,'CDN', 26,'USD', 27,'JPY', 28,'EUR', 29,'AUD', 30,'CDN', 31,'USD', 32,'JPY', 33,'EUR', 34,'AUD', 35,'CHF'),effdt,ROUND(DBMS_RANDOM.VALUE(1,5),6) ); IF MOD(ctr, 5000) = 0 THEN COMMIT; END IF; END LOOP; COMMIT; EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('Fatal unexpected error has occurred: ' || SQLERRM ); END; / Generates 36,000 rows of historical test data for conversions between six key currencies SQL> UPDATE oe.currency_conversions ora_archive_state 10 SET ora_archive_state = 10 GBP WHERE (currency_from = 'GBP') GBP OR (currency_to = 'GBP'); COMMIT; Activates IDA for any rows that convert currencies from or to British Pounds

11 Activating IDA Cloaking row archival visibilityACTIVE SQL> ALTER SESSION SET row archival visibility = ACTIVE; COL currency_from FORMAT A08 HEADING "From|Currency" COL currency_to FORMAT A08 HEADING "To|Currency" COL effect_cdtm FORMAT A19 HEADING "Effective As Of:" COL conversion_fctr FORMAT HEADING "Currency|Conversion|Factor" COL min_dtm FORMAT A19 HEADING "Minimum|Effective|Date" COL max_dtm FORMAT A19 HEADING "Maximum|Effective|Date" COL min_cvf FORMAT HEADING "Minimum|Currency|Conversion|Factor" COL max_cvf FORMAT HEADING "Maximum|Currency|Conversion|Factor" TTITLE "Active Currency Conversion Factors|(from OE.CURRENCY_CONVERSIONS)" SELECT currency_from,currency_to,TO_CHAR(MIN(effect_dtm), 'yyyy-mm-dd hh24:mi') min_dtm,TO_CHAR(MAX(effect_dtm), 'yyyy-mm-dd hh24:mi') max_dtm,MIN(conversion_fctr) min_cvf,MAX(conversion_fctr) max_cvf FROM oe.currconv_parted GROUP BY currency_from, currency_to ORDER BY currency_from, currency_to ; TTITLE OFF s Active Currency Conversion Factors (from OE.CURRENCY_CONVERSIONS) Minimum Maximum Minimum Maximum Currency Currency From To Effective Effective Conversion Conversion Currency Currency Date Date Factor Factor AUD CDN : : AUD CHF : : AUD EUR : : AUD JPY : : AUD USD : : CHF AUD : : CHF CDN : : JPY EUR : : JPY USD : : USD AUD : : USD CDN : : USD CHF : : USD EUR : : USD JPY : : rows selected. No results for British Pound appear … SQL> SELECT currency_from, currency_to, TO_CHAR(effect_dtm, 'yyyy-mm-dd hh24:mi'), conversion_fctr FROM oe.currency_conversions GBP WHERE (currency_from = 'GBP') GBP OR (currency_to = 'GBP') ORDER BY 1,2,3; no rows selected … and all British Pound entries are cloaked!

12 Deactivating IDA Cloaking row archival visibility SQL> ALTER SESSION SET row archival visibility = ALL; Active Currency Conversion Factors (from OE.CURRENCY_CONVERSIONS) Minimum Maximum Minimum Maximum Currency Currency From To Effective Effective Conversion Conversion Currency Currency Date Date Factor Factor AUD CDN : : AUD CHF : : AUD EUR : : AUD GBP : : EUR GBP : : EUR JPY : : EUR USD : : GBP AUD : : GBP CDN : : GBP CHF : : GBP EUR : : GBP JPY : : GBP USD : : USD GBP : : USD JPY : : rows selected. Inactive Currency Conversion Factors From To Conversion Currency Currency Effective As Of: Factor AUD GBP : CDN GBP : CHF GBP : EUR GBP : GBP AUD : GBP USD : JPY GBP : USD GBP : rows selected. Cloaking device … off.

13 Temporal Validity (TV) and Temporal History (TH)

14 Temporal Validity (TV) TV allows specification of time periods when data stored within a table will be actually considered valid PERIOD FORImplemented through new PERIOD FOR table attribute Specified TV dimension can then be populated as desired with both time-valid and non-time- valid data Non-time-valid data can be compressed until its no longer needed

15 Implementing TV: Examples DROP TABLE oe.product_pricing PURGE; CREATE TABLE oe.product_pricing ( product_id NUMBER(6) NOT NULL,unit_price NUMBER(10,6) DEFAULT 0,beg_dtm TIMESTAMP NOT NULL,end_dtm TIMESTAMP NOT NULL PERIOD FOR effective,PERIOD FOR effective (beg_dtm, end_dtm) ) TABLESPACE example; … or, if columns are specified during the tables creation, theyll be used as the new dimension columns DROP TABLE oe.product_pricing PURGE; CREATE TABLE oe.product_pricing ( product_id NUMBER(6) NOT NULL,unit_price NUMBER(10,6) DEFAULT 0,beg_dtm TIMESTAMP NOT NULL,end_dtm TIMESTAMP NOT NULL PERIOD FOR effective,PERIOD FOR effective ) TABLESPACE example; The new dimension can be specified without any predefined columns, and they will be created automatically …

16 TV: Populating Sample Data DECLARE ctr NUMBER := 0; begdt DATE := TO_DATE('01/01/2000','mm/dd/yyyy'); enddt DATE; BEGIN FOR ctr IN LOOP enddt := ADD_MONTHS(begdt, 1); FOR pidx IN LOOP INSERT INTO oe.pricing_parted VALUES( DECODE(MOD(pidx,10), 0,1726, 1,1729, 2,1733, 3,1734, 4,1737, 5,1801, 6,2056, 7,2058, 8,3399, 9,3400, 3515),ROUND(DBMS_RANDOM.VALUE(1,100),4),begdt,enddt ); END LOOP; begdt := enddt; END LOOP; COMMIT; EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('Fatal unexpected error has occurred: ' || SQLERRM ); END; / Adds 1,800 rows of randomized data for Temporal Validity testing

17 Leveraging TV Session-Level Filtering CONNECT / AS SYSDBA DBMS_FLASHBACK_ARCHIVEoe GRANT EXECUTE ON DBMS_FLASHBACK_ARCHIVE TO oe; valid time window GRANTs access to users to request a valid time window -- Summary of all product prices: SELECT product_id,TO_CHAR(MIN(beg_dtm), 'yyyy-mm-dd.hh24:mi:ss') start_dtm,TO_CHAR(MAX(end_dtm), 'yyyy-mm-dd.hh24:mi:ss') stop_dtm,MIN(unit_price) min_price,MAX(unit_price) max_price FROM oe.pricing_parted GROUP BY product_id ORDER BY product_id; -- Detail for a single product: SELECT product_id,unit_price,TO_CHAR(beg_dtm,'YYYY-MM-DD') beg_dte,TO_CHAR(end_dtm,'YYYY-MM-DD') end_dte FROM oe.pricing_parted WHERE product_id = 1726 ORDER BY product_id, beg_dtm; EXEC DBMS_FLASHBACK_ARCHIVE.ENABLE_AT_VALID_TIME(level => ALL'); Summary of Unit Pricing Statistics Within Product ID (from OE.PRICING_PARTED) Starting Ending Product Time Time Minimum Maximum # Entries Period Period Unit Price Unit Price :00: :00: :00: :00: :00: :00: :00: :00: rows selected. Detailed Product Pricing for 1726 (from OE.PRICING_PARTED) Starting Ending Product Unit Time Time # Price Period Period :00: :00: :00: :00: :00: :00: :00: :00: rows selected. EXEC DBMS_FLASHBACK_ARCHIVE.ENABLE_AT_VALID_TIME(level => ASOF, query_time => (TO_TIMESTAMP(' ','yyyy-mm-dd))); Summary of Unit Pricing Statistics Within Product ID (from OE.PRICING_PARTED) Starting Ending Product Time Time Minimum Maximum # Entries Period Period Unit Price Unit Price :00: :00: :00: :00: :00: :00: :00: :00: :00: :00: :00: :00: :00: :00: :00: :00: :00: :00: :00: :00: Detailed Product Pricing for 1726 (from OE.PRICING_PARTED) Starting Ending Product Unit Time Time # Price Period Period :00: :00:00 EXEC DBMS_FLASHBACK_ARCHIVE.ENABLE_AT_VALID_TIME(level => CURRENT'); Summary of Unit Pricing Statistics Within Product ID (from OE.PRICING_PARTED) Starting Ending Product Time Time Minimum Maximum # Entries Period Period Unit Price Unit Price :00: :00: :00: :00: :00: :00: :00: :00: :00: :00: :00: :00: :00: :00: :00: :00: :00: :00: :00: :00: Detailed Product Pricing for 1726 (from OE.PRICING_PARTED) Starting Ending Product Unit Time Time # Price Period Period :00: :00:00

18 Temporal History (TH) Original name: Oracle Total Recall Later releases: Flashback Data Archive Intrinsic to Oracle 12cR1 Permits bi-temporal queries: Flashback Query uses AS OF clause Flashback Versions Query uses VERSIONS BETWEEN clause

19 Leveraging Bi-Temporal Queries Changed on Changed on Changed on SCNSCN Time EXEC DBMS_FLASHBACK_ARCHIVE(ASOF, ); SELECT product_id,unit_price,TO_CHAR(beg_dtm,'YYYY-MM-DD') beg_dte,TO_CHAR(end_dtm,'YYYY-MM-DD') end_dte FROM oe.pricing_parted AS OF PERIOD FOR effective TO_DATE(' ','yyyy-mm-dd') AS OF PERIOD FOR effective TO_DATE(' ','yyyy-mm-dd') WHERE product_id = 1726 ORDER BY product_id, beg_dtm; Flashback Query EXEC DBMS_FLASHBACK_ARCHIVE(ASOF, ); SELECT product_id,unit_price,TO_CHAR(beg_dtm,'YYYY-MM-DD') beg_dte,TO_CHAR(end_dtm,'YYYY-MM-DD') end_dte FROM oe.pricing_parted VERSIONS PERIOD FOR effective PERIOD FOR effective BETWEEN TO_DATE(' ','yyyy-mm-dd') BETWEEN TO_DATE(' ','yyyy-mm-dd') AND TO_DATE(' ','yyyy-mm-dd') AND TO_DATE(' ','yyyy-mm-dd') WHERE product_id = 1726 ORDER BY product_id, beg_dtm; Flashback Versions Query

20 Leveraging ILM ADO Features

21 Automatic Data Optimization (ADO) Moves or compresses data based on observed usage patterns Leverages heat maps to determine how often data has been accessed Tracks exactly how data has been utilized DML versus query Random access versus table scan Usage patterns can be tracked at tablespace, segment, and even row level

22 Covering the Space-Time Continuum An ADO policy can be based on either space or time Space-based: Moves segment between tablespaces in different storage tiers Movement is based on fullness of initial tablespace Time-based: Compresses data more tightly within same object Data compressible at three levels: ROW STORAGE (row level within a segment) SEGMENT (one database object at segment level) GROUP (multiple database objects)

23 IDA: Implementing ILM Storage Tiering CREATE table oe.currconv_parted ( currency_from VARCHAR2(3) NOT NULL,currency_to VARCHAR2(3) NOT NULL,effect_dtm TIMESTAMP NOT NULL,conversion_fctr NUMBER(10,6) DEFAULT 0 ) PARTITION BY LIST(ora_archive_state) ( PARTITION currconv_history VALUES (10,20,30,40,50) TABLESPACE ado_cold_data ILM ADD POLICY COMPRESS FOR QUERY HIGH COMPRESS FOR QUERY HIGH SEGMENT SEGMENT AFTER 180 DAYS OF NO MODIFICATION AFTER 180 DAYS OF NO MODIFICATION,PARTITION currconv_current VALUES (0) TABLESPACE ado_hot_data ) ROW ARCHIVAL NOLOGGING PARALLEL 4; 180 days compressed HCC QUERY HIGH After 180 days of no further DML activity, the segment of the partition containing all inactive rows will be compressed using HCC QUERY HIGH compression

24 TV: Implementing ILM Storage Tiering CREATE TABLE oe.pricing_parted ( product_id NUMBER(6) NOT NULL,unit_price NUMBER(10,6) DEFAULT 0,beg_dtm TIMESTAMP NOT NULL,end_dtm TIMESTAMP NOT NULL,PERIOD FOR EFFECTIVE (beg_dtm, end_dtm) ) PARTITION BY RANGE(end_dtm) ( PARTITION opp_history VALUES LESS THAN (TO_DATE(' ','yyyy-mm-dd')) TABLESPACE ado_cold_data ILM ADD POLICY COMPRESS FOR QUERY HIGH COMPRESS FOR QUERY HIGH SEGMENT SEGMENT AFTER 180 DAYS OF NO ACCESS AFTER 180 DAYS OF NO ACCESS,PARTITION opp_current VALUES LESS THAN (MAXVALUE) TABLESPACE ado_warm_data ) NOLOGGING PARALLEL 4;

25 Over To You …

26 Please feel free to evaluate this session: Use the COLLABORATE14 Application! Session #187 Something Old, Something New: Leveraging Oracle 12cs Information Lifecycle Management (ILM) Features for Improved Database Performance If you have any questions or comments, feel free to: me at Follow my blog (Generally, It Depends): Connect with me on LinkedIn (Jim Czuprynski) Follow me on Twitter Thank You For Your Kind Attention


Download ppt "REMINDER Check in on the COLLABORATE mobile app Something Old, Something New: Leveraging Oracle 12cs Information Lifecycle Management (ILM) Features for."

Similar presentations


Ads by Google