precisely my point: leverage attribute clustering and zone mapping in oracle database 12.1.0.2

28
Precisely My Point: Leverage Attribute Clustering and Zone Mapping in Oracle Database 12.1.0.2

Upload: rhoda-rose

Post on 23-Dec-2015

227 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Precisely My Point: Leverage Attribute Clustering and Zone Mapping in Oracle Database 12.1.0.2

Precisely My Point: Leverage Attribute Clustering

and Zone Mapping in Oracle Database 12.1.0.2

Page 2: Precisely My Point: Leverage Attribute Clustering and Zone Mapping in Oracle Database 12.1.0.2

My Credentials

30+ years of database-centric IT experience Oracle DBA since 2001 Oracle 9i, 10g, 11g OCP Oracle ACE Director > 100 articles on databasejournal.com and ioug.org Oracle-centric blog (Generally, It Depends) Regular speaker at Oracle OpenWorld, IOUG

COLLABORATE, and OTN ACE Tours Oracle University instructor – core Oracle DBA

courses

Page 3: Precisely My Point: Leverage Attribute Clustering and Zone Mapping in Oracle Database 12.1.0.2

Coming Soon To a Bookstore Near You …

Coming in June 2015 from Oracle Press:Oracle Database Upgrade, Migration &

Transformation Tips & Techniques

• Covers everything you need to know to upgrade, migrate, and transform any Oracle 10g or 11g database to Oracle 12c

• Discusses strategy and tactics of planning Oracle migration, transformation, and upgrade projects

• Explores latest transformation features:• Recovery Manager (RMAN)• Oracle GoldenGate• Cross-Platform Transportable Tablespaces• Cross-Platform Transport (CPT)• Full Transportable Export (FTE)

• Includes detailed sample code

Page 4: Precisely My Point: Leverage Attribute Clustering and Zone Mapping in Oracle Database 12.1.0.2

Our Agenda

Attribute Clustering Improving physical I/O for tables and table partitions Limiting the need for those nasty indexes

Zone Mapping Accurately ascertaining exactly where data is located on

spinning disk Enabling I/O pruning

Improving query performance without expensive alternative index structures

Q+A

Page 5: Precisely My Point: Leverage Attribute Clustering and Zone Mapping in Oracle Database 12.1.0.2

Attribute Clustering:Ordering Data for Faster

Retrieval

5

Page 6: Precisely My Point: Leverage Attribute Clustering and Zone Mapping in Oracle Database 12.1.0.2

Attribute Clustering (AC)

AC provides several advantages for query execution: Reduces cost of locating commonly-accessed data

when filtering predicates are applied Significantly reduces the need for indexing

Reorders table row pieces into an appropriate sorted order based on chosen clustering method

Table data is now more effectively “locatable” without the need for additional indexes

Complements In-Memory Column Store (IMCS) and In-Memory Aggregation (IMA) features

Especially powerful when paired with Zone Mapping

Page 7: Precisely My Point: Leverage Attribute Clustering and Zone Mapping in Oracle Database 12.1.0.2

AC: LINEAR vs. INTERVAL Clustering

AC offers two mutually-exclusive clustering methods: LINEAR clustering is most effective when:

Data can be ordered almost precisely the way most queries will request it

Query workloads are well-known and predictable (think: Business Intelligence)

INTERVAL clustering is most effective when: Data can be grouped together in a practical pattern, but

not necessarily one best order exists for all queries Requests are unpredictable (think: Ad Hoc)

Page 8: Precisely My Point: Leverage Attribute Clustering and Zone Mapping in Oracle Database 12.1.0.2

AC: Implementing LINEAR Clustering

Apply LINEAR clustering to SH.ZM_SALES:SQL> ALTER TABLE sh.zm_sales DROP CLUSTERING;*ERROR at line 1:ORA-65411: CLUSTERING clause does not exist

SQL> ALTER TABLE sh.zm_sales ADD CLUSTERING BY LINEAR ORDER (cust_id, prod_id) YES ON LOAD YES ON DATA MOVEMENT WITHOUT MATERIALIZED ZONEMAP;

Table altered.

SQL> ALTER TABLE sh.zm_sales MOVE ALLOW CLUSTERING;Table altered.

SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS('SH','ZM_SALES');PL/SQL procedure completed.

Page 9: Precisely My Point: Leverage Attribute Clustering and Zone Mapping in Oracle Database 12.1.0.2

AC: Proof of LINEAR Clustering

Simple query against SH.ZM_SALES with INTERVAL clustering activated:

SQL> SELECT ROWID, cust_id, prod_id, quantity_sold, amount_sold FROM sh.sales WHERE rownum < 101;

ROWID CUST_ID PROD_ID QUANTITY_SOLD AMOUNT_SOLD------------------ ---------- ---------- ------------- -----------AAAW1dAAKAAAmISAAA 2 13 1 1232.16AAAW1dAAKAAAmISAAB 2 14 1 1259.99AAAW1dAAKAAAmISAAC 2 14 1 1259.99AAAW1dAAKAAAmISAAD 2 14 1 1259.99. . . AAAW1dAAKAAAmISAAq 2 146 1 16.79AAAW1dAAKAAAmISAAr 2 146 1 16.79AAAW1dAAKAAAmISAAs 2 148 1 29.39AAAW1dAAKAAAmISAAt 7 41 1 48.36AAAW1dAAKAAAmISAAu 7 42 1 48.36AAAW1dAAKAAAmISAAv 7 45 1 48.36AAAW1dAAKAAAmISAAw 8 19 1 63.02AAAW1dAAKAAAmISAAx 8 19 1 63.02AAAW1dAAKAAAmISAAy 8 23 1 24.08AAAW1dAAKAAAmISAAz 8 25 1 128.32. . . AAAW1dAAKAAAmISABh 9 128 1 28.86AAAW1dAAKAAAmISABi 9 128 1 28.86AAAW1dAAKAAAmISABj 9 128 1 28.86

100 rows selected.

` `

Note that ROWIDs of row pieces precisely match sorted order of CUST_ID and PROD_ID

Page 10: Precisely My Point: Leverage Attribute Clustering and Zone Mapping in Oracle Database 12.1.0.2

AC: INTERVAL Clustering & Z-Order Curves

Most effective when data grouping is possible, but data grouping

requests are unpredictable

■ Groups related data into boxed sets using a backwards-Z search pattern

■ Records minimum and maximum values for each boxed set via extremely efficient bitmaps

■ In theory, these patterns can be mapped almost infinitely

INTERVAL clustering uses Z-Order Curve methods to group data:

Page 11: Precisely My Point: Leverage Attribute Clustering and Zone Mapping in Oracle Database 12.1.0.2

AC: Implementing INTERVAL Clustering

Activate INTERVAL clustering against SH.ZM_SALES:SQL> ALTER TABLE sh.zm_sales DROP CLUSTERING;

Table altered.

SQL> ALTER TABLE sh.zm_sales ADD CLUSTERING BY INTERVAL ORDER (cust_id, prod_id) YES ON LOAD YES ON DATA MOVEMENT WITHOUT MATERIALIZED ZONEMAP;Table altered.

SQL> ALTER TABLE sh.zm_sales MOVE ALLOW CLUSTERING;Table altered.

SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS('SH','ZM_SALES');PL/SQL procedure completed.

Page 12: Precisely My Point: Leverage Attribute Clustering and Zone Mapping in Oracle Database 12.1.0.2

AC: Results of INTERVAL Clustering

Simple query against SH.ZM_SALES with INTERVAL clustering activated:

SQL> SELECT ROWID, cust_id, prod_id, quantity_sold, amount_sold FROM sh.sales WHERE rownum < 101;

ROWID CUST_ID PROD_ID QUANTITY_SOLD AMOUNT_SOLD------------------ ---------- ---------- ------------- -----------AAAWeZAAKAAABiSAAA 987 13 1 1232.16AAAWeZAAKAAABiSAAB 1660 13 1 1232.16AAAWeZAAKAAABiSAAC 1762 13 1 1232.16AAAWeZAAKAAABiSAAD 1843 13 1 1232.16AAAWeZAAKAAABiSAAE 1948 13 1 1232.16. . .AAAWeZAAKAAABiSAAX 659 13 1 1232.16AAAWeZAAKAAABiSAAY 848 13 1 1232.16AAAWeZAAKAAABiSAAZ 949 13 1 1232.16AAAWeZAAKAAABiSAAa 1242 13 1 1232.16AAAWeZAAKAAABiSAAb 1291 13 1 1232.16AAAWeZAAKAAABiSAAc 1422 13 1 1232.16AAAWeZAAKAAABiSAAd 1485 13 1 1232.16AAAWeZAAKAAABiSAAe 1580 13 1 1232.16. . .AAAWeZAAKAAABiSAA2 14457 13 1 1232.16AAAWeZAAKAAABiSAA3 17011 13 1 1232.16AAAWeZAAKAAABiSAA4 17566 13 1 1232.16AAAWeZAAKAAABiSAA5 17633 13 1 1232.16AAAWeZAAKAAABiSAA6 2 13 1 1232.16

` `

Although these ROWIDs may appear to be sorted haphazardly, they actually map precisely to a Z-Order Curve distribution of values for CUST_ID and PROD_ID

Page 13: Precisely My Point: Leverage Attribute Clustering and Zone Mapping in Oracle Database 12.1.0.2

AC: JOIN Ordered Clustering

AC now also makes it possible to order data within a fact table based on how it’s ordered in one or more underlying dimensions Fact table data can be ordered based on

commonly used dimensional data to enhance its retrieval speed

The fact table’s primary keys columns or other non-key columns can be completely ignored when ordering table data

This has never really been possible before!

Page 14: Precisely My Point: Leverage Attribute Clustering and Zone Mapping in Oracle Database 12.1.0.2

AC: Implementing JOIN Ordered Clustering

Apply join-ordered LINEAR clustering to SH.ZM_SALES based on product category

attributes of SH.ZM_PRODUCTS dimension:

ALTER TABLE sh.zm_sales ADD CLUSTERING sh.zm_sales JOIN sh.zm_products ON (sh.zm_sales.prod_id = sh.zm_products.prod_id) BY LINEAR ORDER ( sh.zm_products.prod_id ,sh.zm_products.prod_category ,sh.zm_products.prod_subcategory) YES ON LOAD YES ON DATA MOVEMENT WITHOUT MATERIALIZED ZONEMAP;

SQL> ALTER TABLE sh.zm_sales ADD CLUSTERING sh.zm_sales JOIN sh.zm_customers ON (sh.zm_sales.cust_id = sh.zm_customers.cust_id) BY INTERVAL ORDER ( sh.zm_customers.country_id ,sh.zm_customers.cust_state_province ,sh.zm_customers.cust_city) YES ON LOAD YES ON DATA MOVEMENT WITHOUT MATERIALIZED ZONEMAP;

Apply join-ordered INTERVAL clustering to SH.ZM_SALES based on location attributes of

SH.ZM_CUSTOMERS dimension:

Page 15: Precisely My Point: Leverage Attribute Clustering and Zone Mapping in Oracle Database 12.1.0.2

AC: Applying Multi-JOIN Ordered Clustering

Apply multi-join, multi-column join-ordered LINEAR clustering to SH.ZM_SALES based on CUSTOMER location and PRODUCT category dimensions data

values:

ALTER TABLE sh.sales ADD CLUSTERING sh.sales JOIN sh.products ON (sh.sales.prod_id = sh.products.prod_id) JOIN sh.customers ON (sh.sales.cust_id = sh.customers.cust_id) BY LINEAR ORDER ( sh.customers.cust_state_province ,sh.customers.cust_city ,sh.products.prod_category ,sh.products.prod_subcategory) YES ON LOAD YES ON DATA MOVEMENT WITHOUT MATERIALIZED ZONEMAP;

Page 16: Precisely My Point: Leverage Attribute Clustering and Zone Mapping in Oracle Database 12.1.0.2

AC: Clustering Factor Results

SQL> CREATE INDEX sh.zm_cust_prod_idx ON sh.zm_sales (cust_id, prod_id) TABLESPACE ado_cold_idx;

An easy way to measure AC impact:

… and then measure

the clustering factor on the index:

SQL> SELECT num_rows ,distinct_keys ,clustering_factor clusfctr ,blevel ,leaf_blocks ,avg_leaf_blocks_per_key avg_lbpk ,avg_data_blocks_per_key avg_dbpk FROM dba_indexes WHERE owner = 'SH' AND table_name = 'ZM_SALES' ORDER BY 1,2,3;

Create an index on appropriate the column(s) in the

clustered table …

Page 17: Precisely My Point: Leverage Attribute Clustering and Zone Mapping in Oracle Database 12.1.0.2

AC: Impact of Methods on Clustering Factor

Impact of Attribute Clustering on Clustering Factor

Clustering Method

Join Ordered Clustering

Resulting Clustering

Factor

Clustering Factor vs. Baseline

None None 747,080 100%

LINEAR None 4,304 0.57%

INTERVAL None 172,923 23.14%

LINEAR SH.PRODUCTS 288,474 38.61%

INTERVALSH.PRODUCTS,SH.CUSTOMERS

208,011 27.84%

Page 18: Precisely My Point: Leverage Attribute Clustering and Zone Mapping in Oracle Database 12.1.0.2

Zone Mapping:Uber-Fast Data Retrieval

from Spinning Disk

18

Page 19: Precisely My Point: Leverage Attribute Clustering and Zone Mapping in Oracle Database 12.1.0.2

Zone Mapping (ZM): Finding Data Faster

Zone Mapping is designed to locate table and table partition data with minimal physical I/O: Pairs nicely with Attribute Clustering features Collaborates with Exadata Storage Indexes Aimed at selected Oracle Enterprise hardware

12.1.0.2: Exadata and SPARC SuperCluster May be offered with other Oracle storage (e.g. ZFS/S3-

4) in future releases May be offered for other enterprise SANs later

Note: ZM is a separately licensed feature!

Page 20: Precisely My Point: Leverage Attribute Clustering and Zone Mapping in Oracle Database 12.1.0.2

Building Zone Maps Using Attribute Clustering

Activate INTERVAL clustering against SH.ZM_SALES … while building a zone map simultaneously

SQL> ALTER TABLE sh.zm_sales DROP CLUSTERING;Table altered.

SQL> ALTER TABLE sh.zm_sales ADD CLUSTERING BY INTERVAL ORDER (cust_id, prod_id) YES ON LOAD YES ON DATA MOVEMENT WITH MATERIALIZED ZONEMAP;Table altered.

SQL> ALTER TABLE sh.zm_sales MOVE ALLOW CLUSTERING;Table altered.

SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS('SH','ZM_SALES');PL/SQL procedure completed.

Page 21: Precisely My Point: Leverage Attribute Clustering and Zone Mapping in Oracle Database 12.1.0.2

Creating a Custom Zone Map

Building a custom Zone Map against fact table SH.ZM_SALES and its corresponding CUSTOMER and PRODUCT dimension tables:

SQL> DROP MATERIALIZED ZONEMAP sh.mzm_sales;CREATE MATERIALIZED ZONEMAP sh.mzm_sales TABLESPACE ado_cold_data REFRESH ON LOAD DATA MOVEMENT AS SELECT SYS_OP_ZONE_ID(S.ROWID) ,MIN(cust_state_province), MAX(cust_state_province) ,MIN(cust_city), MAX(cust_city) ,MIN(prod_category), MAX(prod_category) ,MIN(prod_subcategory), MAX(prod_subcategory) FROM sh.zm_sales S LEFT OUTER JOIN sh.zm_products P ON S.prod_id = P.prod_id LEFT OUTER JOIN sh.zm_customers C ON S.cust_id = C.cust_id GROUP BY sys_op_zone_id(S.ROWID);

Page 22: Precisely My Point: Leverage Attribute Clustering and Zone Mapping in Oracle Database 12.1.0.2

Putting It All Together:Attribute Clustering + Zone

Mapping

22

Page 23: Precisely My Point: Leverage Attribute Clustering and Zone Mapping in Oracle Database 12.1.0.2

Leveraging AC + ZM with Star Schema QueriesA typical star schema query against SALES fact table and corresponding CUSTOMER and PRODUCT dimensions:

SELECT C.cust_state_province ,C.cust_city ,P.prod_category ,P.prod_subcategory ,SUM(S.quantity_sold) ,SUM(S.amount_sold) FROM sh.zm_sales S ,sh.zm_products P ,sh.zm_customers C WHERE S.prod_id = P.prod_id AND S.cust_id = C.cust_id AND C.cust_city = 'Bay City' AND C.cust_state_province = 'WI' AND P.prod_category = 'Software/Other' GROUP BY P.prod_category, P.prod_subcategory ,C.cust_state_province, C.cust_city ORDER BY P.prod_category, P.prod_subcategory ,C.cust_state_province, C.cust_city;

Plan hash value: 2722944393----------------------------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost |----------------------------------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 11 | 858 | 1624|| 1 | SORT GROUP BY | | 11 | 858 | 1624||* 2 | HASH JOIN | | 16 | 1248 | 1623|| 3 | JOIN FILTER CREATE | :BF0000 | 9 | 549 | 425|| 4 | MERGE JOIN CARTESIAN | | 9 | 549 | 425||* 5 | TABLE ACCESS STORAGE FULL | ZM_CUSTOMERS | 1 | 26 | 423|| 6 | BUFFER SORT | | 14 | 490 | 2|| 7 | TABLE ACCESS BY INDEX ROWID BATCHED | ZM_PRODUCTS | 14 | 490 | 2||* 8 | INDEX RANGE SCAN | ZM_PRODUCTS_PROD_CAT_IX | 14 | | 0|| 9 | JOIN FILTER USE | :BF0000 | 918K| 14M| 1196||* 10 | TABLE ACCESS STORAGE FULL WITH ZONEMAP| ZM_SALES | 918K| 14M| 1196|----------------------------------------------------------------------------------------------------Predicate Information (identified by operation id):---------------------------------------------------. . . 10 - storage(SYS_OP_BLOOM_FILTER(:BF0000,"S"."PROD_ID","S"."CUST_ID")) filter(SYS_ZMAP_FILTER('/* ZM_PRUNING */ SELECT "ZONE_ID$", CASE WHEN BITAND(zm."ZONE_STATE$",1)=1 THEN 1 ELSE CASE WHEN (zm."MIN_3_PROD_CATEGORY" > :1 OR zm."MAX_3_PROD_CATEGORY" < :2 OR zm."MIN_2_CUST_CITY" > :3 OR zm."MAX_2_CUST_CITY" < :4 OR zm."MIN_1_CUST_STATE_PROVINCE" > :5 OR zm."MAX_1_CUST_STATE_PROVINCE" < :6) THEN 3 ELSE 2 END END FROM "SH"."MZM_SALES" zm WHERE zm."ZONE_LEVEL$"=0 ORDER BY zm."ZONE_ID$"',SYS_OP_ZONE_ID(ROWID),'Software/Other','Software/Other','Bay City','Bay City','WI','WI')<3 AND SYS_OP_BLOOM_FILTER(:BF0000,"S"."PROD_ID","S"."CUST_ID"))

Page 24: Precisely My Point: Leverage Attribute Clustering and Zone Mapping in Oracle Database 12.1.0.2

Zone Mapping: Partnering with Partitioning

CREATE TABLE ap.randomized_parted ( key_id NUMBER(8) ,key_date DATE ,key_desc VARCHAR2(32) ,key_sts NUMBER(2) NOT NULL) CLUSTERING BY LINEAR ORDER (key_sts) YES ON LOAD YES ON DATA MOVEMENT WITH MATERIALIZED ZONEMAP (zm_randomized_parted) PARTITION BY RANGE(key_date) ( PARTITION p1_frigid VALUES LESS THAN (TO_DATE('2010-01-01','yyyy-mm-dd')) TABLESPACE ado_cold_data ,PARTITION p2_cool VALUES LESS THAN (TO_DATE('2013-01-01','yyyy-mm-dd')) TABLESPACE ado_cool_data ,PARTITION p3_warm VALUES LESS THAN (TO_DATE('2014-01-01','yyyy-mm-dd')) TABLESPACE ado_warm_data ,PARTITION p4_hot VALUES LESS THAN (TO_DATE('2014-07-01','yyyy-mm-dd')) TABLESPACE ado_hot_data ,PARTITION p5_radiant VALUES LESS THAN (MAXVALUE) TABLESPACE ap_data);

Page 25: Precisely My Point: Leverage Attribute Clustering and Zone Mapping in Oracle Database 12.1.0.2

Zone Mapping: Partition Pruning

EXPLAIN PLAN FOR SELECT MIN(key_id), MAX(key_id), COUNT(*) FROM ap.randomized_parted WHERE key_date BETWEEN TO_DATE('2014-01-01','YYYY-MM-DD') AND TO_DATE('2014-09-30','YYYY-MM-DD') AND key_sts < 50; SELECT plan_table_output FROM TABLE(DBMS_XPLAN.DISPLAY(FORMAT => 'BASIC PREDICATE PARTITION'));

Plan hash value: 4272865020-----------------------------------------------------------------------------------------| Id | Operation | Name | Pstart| Pstop |-----------------------------------------------------------------------------------------| 0 | SELECT STATEMENT | | | || 1 | SORT AGGREGATE | | | || 2 | PX COORDINATOR | | | || 3 | PX SEND QC (RANDOM) | :TQ10000 | | || 4 | SORT AGGREGATE | | | || 5 | PX BLOCK ITERATOR | |KEY(AP)|KEY(AP)||* 6 | TABLE ACCESS STORAGE FULL WITH ZONEMAP| RANDOMIZED_PARTED |KEY(AP)|KEY(AP)|-----------------------------------------------------------------------------------------

Predicate Information (identified by operation id):---------------------------------------------------

6 - storage("KEY_STS"<50 AND "KEY_DATE"<=TO_DATE(' 2014-09-30 00:00:00', 'syyyy-mm-dd hh24:mi:ss')) filter(SYS_ZMAP_FILTER('/* ZM_PRUNING */ SELECT "ZONE_ID$", CASE WHEN BITAND(zm."ZONE_STATE$",1)=1 THEN 1 ELSE CASE WHEN (zm."MIN_1_KEY_STS" >= :1) THEN 3 ELSE 2 END END FROM "AP"."ZM_RANDOMIZED_PARTED" zm WHERE zm."ZONE_LEVEL$"=0 ORDER BY zm."ZONE_ID$"',SYS_OP_ZONE_ID(ROWID),50)<3 AND "KEY_STS"<50 AND "KEY_DATE"<=TO_DATE(' 2014-09-30 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))

Page 26: Precisely My Point: Leverage Attribute Clustering and Zone Mapping in Oracle Database 12.1.0.2

Viewing AC and ZM Metadata

DBA_CLUSTERING_* and DBA_ZONEMAPS_* views contain current metadata about Attribute Clustering and Zone Mapping settings for tables and table partitions:Metadata View Purpose

DBA_CLUSTERING_ TABLES Shows which tables have at least one Attribute Cluster

DBA_CLUSTERING_ KEYS Displays keys and values controlling Attribute Clustering

DBA_CLUSTERING_ DIMENSIONS

Lists which dimensions are used to control sorting and ordering within fact tables

DBA_CLUSTERING_JOINSShows which ancillary tables are participating as dimensions to control AC ordering of fact table row pieces

DBA_ZONEMAPSDescribes Zone Map metadata, including when a Zone Map was refreshed

DBA_ZONEMAP_MEASURESDescribes functional methods the Zone Map has utilized to map out data (e.g. MIN/MAX to enable pruning)

Page 27: Precisely My Point: Leverage Attribute Clustering and Zone Mapping in Oracle Database 12.1.0.2

Viewing AC Metadata: Examples

TTITLE "Clustering Attribute Metadata|(from DBA_CLUSTERING_TABLES)"SELECT owner ,table_name ,clustering_type cls_type ,on_load cls_onld ,on_datamovement cls_ondm ,with_zonemap wzmap FROM dba_clustering_tables WHERE owner IN ('AP','SH','TPCH') ORDER BY 1,2;TTITLE OFF TTITLE "Clustering Columns Metadata|(from DBA_CLUSTERING_KEYS)"SELECT detail_owner owner ,position ,detail_name table_name ,detail_column column_name FROM dba_clustering_keys WHERE owner IN ('AP','SH','TPCH') ORDER BY 1,2,3;TTITLE OFF

Clustering Attribute Metadata (from DBA_CLUSTERING_TABLES)

Cluster Cluster WithTable Cluster On Data On Data ZoneOwner Table Name Type Loads? Moves? Map?------------ ------------------------------ ------------ -------- -------- --------SH ZM_SALES LINEAR YES YES NOTPCH H_LINEITEM INTERVAL YES YES NO

Clustering Columns Metadata (from DBA_CLUSTERING_KEYS)

Table PosOwner Table Name # Column Name------------ ------------------------------ ---- ------------------------------SH ZM_SALES 1 CUST_IDSH ZM_SALES 2 PROD_IDTPCH H_ORDER 1 O_ORDERDATETPCH H_ORDER 2 O_ORDERSTATUS

TTITLE "Clustering Dimensions|(from DBA_CLUSTERING_DIMENSIONS)"SELECT owner ,table_name ,dimension_owner dim_owner ,dimension_name dim_name FROM dba_clustering_dimensions WHERE owner IN ('AP','SH','TPCH') ORDER BY 1,2,3;TTITLE OFF

TTITLE "Clustering Dimensions|(from DBA_CLUSTERING_JOINS)"SELECT owner ,table_name ,tab1_owner ,tab1_name ,tab1_column ,tab2_owner ,tab2_name ,tab2_column FROM dba_clustering_joins WHERE tab1_owner IN ('AP','SH','TPCH') ORDER BY 1,2,3;TTITLE OFF

Clustering Dimensions (from DBA_CLUSTERING_DIMENSIONS)

Table DimensionOwner Table Name Owner Dimension Name------------ ------------------------------ ------------ ------------------------------TPCH H_LINEITEM TPCH H_ORDER

Clustering Dimensions (from DBA_CLUSTERING_JOINS)

Join JoinedTable Join Join Table Joined JoinedOwner Table Name Column Name Owner Table Name Column Name------------ --------------- --------------- ------------ --------------- ---------------TPCH H_LINEITEM L_ORDERKEY TPCH H_ORDER O_ORDERKEY

Page 28: Precisely My Point: Leverage Attribute Clustering and Zone Mapping in Oracle Database 12.1.0.2

Viewing ZM Metadata: Examples

SELECT owner ,zonemap_name ,fact_owner ,fact_table ,scale ,hierarchical ,with_clustering ,pruningFROM dba_zonemaps WHERE owner IN ('AP','SH','TPCH') ORDER BY 1,2,3,4;

SELECT owner ,zonemap_name ,refresh_mode ,refresh_method ,last_refresh_method last_rfsh_mthd ,TO_CHAR(last_refresh_time,"yyyy-mm-dd.mi:ss") last_rfsh_dtm ,invalid ,stale ,unusable ,compile_state FROM dba_zonemaps WHERE owner IN ('AP','SH','TPCH') ORDER BY 1,2,3,4;

Zone Mapping Metadata (from DBA_ZONEMAPS) Zone Fact MapZone Map Table Scale With PruningOwner Zone Map Name Owner Fact Table Name Scale Fctr Clst? Enabled?-------- ----------------- ------------ ------------------------------ ---------- ------------ ----- --------SH MZM_SALES SH ZM_SALES 10 NO NO ENABLED

Zone Mapping Metadata (from DBA_ZONEMAPS) LastZone Map Refresh Refresh Refresh Last CompileOwner Zone Map Name Mode Method Method Refresh Dtm Invalid? Stale? Unusable State-------- ------------- ----------------- --------- ----------- ----------- -------- -------- -------- ------SH MZM_SALES LOAD DATAMOVEMENT FORCE COMPLETE 2015-02-19. NO NO NO VALID

TTITLE "Zone Mapping Metadata|(from DBA_ZONEMAP_MEASURES)"SELECT owner ,zonemap_name ,position_in_select position ,agg_function ,agg_column_name column_name FROM dba_zonemap_measures WHERE owner IN ('AP','SH','TPCH') ORDER BY 1,2,3;TTITLE OFF

SELECT min_1_cust_id ,max_1_cust_id ,min_2_prod_id ,max_2_prod_id ,zone_level$ ,zone_state$ ,zone_rows$ FROM sh.mzm_sales ORDER BY 1,2,3,4;

Zone Mapping Metadata (from DBA_ZONEMAP_MEASURES)  PosZone Map In AggregateOwner Zone Map Name SELECT Function Column Name--------- -------------------- ------ ----------------- -----------------SH MZM_SALES 2 MIN MIN_1_CUST_IDSH MZM_SALES 3 MAX MAX_1_CUST_IDSH MZM_SALES 4 MIN MIN_2_PROD_IDSH MZM_SALES 5 MAX MAX_2_PROD_ID

MIN_1_CUST_ID MAX_1_CUST_ID MIN_2_PROD_ID MAX_2_PROD_ID ZONE_LEVEL$ ZONE_STATE$ ZONE_ROWS$------------- ------------- ------------- ------------- ----------- ----------- ---------- 2 324 13 148 0 0 25495 324 2506 13 148 0 0 216496 2506 4897 13 148 0 0 216526 4897 8809 13 148 0 0 216518 8809 28700 13 148 0 0 211813 28700 101000 13 148 0 0 31995