Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
CBO Basics: Cardinality<br />Sidney Chen@zha-dba<br />
Agenda<br />Cardinality<br />The Cardinality under Various Prediction<br />Case study: incorrect high value<br />
Cardinality<br />The estimated number of rows <br />a query is expected to return.<br />Number of rows in table<br />x<br ...
Imaging there are 1200 people attend the dba weekly meeting, <br />They are randomly born in 12 month and comes from 10 ci...
sid@CS10G> select month_no, count(*) from audience group by month_no order by month_no;<br />  MONTH_NO   COUNT(*)<br />--...
sid@CS10G> select city_no, count(*) from audience group by city_no order by city_no;<br />   CITY_NO   COUNT(*)<br />-----...
sid@CS10G> @indsid.audience;<br />OWNER TABLE_NAME     BLOCKS   NUM_ROWS AVG_ROW_LEN<br />----- ---------- ---------- ----...
Critical info<br />NDK: number of distinct keys<br /> Density = 1/NDK, (0.1 = 1/10) (0.083333333 = 1/12)<br />NUM_BUCKETS=...
    select month_no from audience where month_no=12;<br />Cardinality<br />1200 * (1/12) = 100<br />
sid@CS10G> select month_no from audience where month_no=12;<br />100 rows selected.<br />Execution Plan<br />-------------...
    select month_no from audience where city_no=1;<br />Cardinality<br />1200 * (1/10) = 120<br />
sid@CS10G> select month_no from audience where city_no=1;<br />120 rows selected.<br />Execution Plan<br />---------------...
 	select month_no from audience where month_no > 9;<br />Cardinality<br />1200 * ( (12-9)/(12-1) ) = 327<br />
sid@CS10G> select month_no from audience where month_no > 9;<br />300 rows selected.<br />Execution Plan<br />------------...
Equality: If Out of range<br />explain plan set statement_id = '12' for select month_no from audience where month_no = 12;...
sid@CS10G> select statement_id, cardinality from plan_table where id=1 order by statement_id;<br />STATEMENT_ID CARDINALIT...
Range: If Out of range<br />explain plan set statement_id = '12' for select month_no from audience where month_no > 12;<br...
sid@CS10G> select statement_id, cardinality from plan_table where id=1 order by statement_id;<br />STATEMENT_ID CARDINALIT...
The far from low/high range, the less you are to find data<br />
Bad news<br />If you have sequence, or time-based column in predicate(such as last modified date:last_mod_dt), and haven’t...
sid@CS10G> select month_no from audience where month_no > 16;<br />no rows selected<br />Execution Plan<br />-------------...
Using 10053 event to confirm<br />sid@CS10G> @53on<br />alter session set events '10053 trace name context forever, level ...
SINGLE TABLE ACCESS PATH<br />  -----------------------------------------<br />  BEGIN Single Table Cardinality Estimation...
Between: If Out of range<br />explain plan set statement_id = '12' for select month_no from audience where month_nobetween...
sid@CS10G> select statement_id, cardinality from plan_table where id=1 order by statement_id;<br />STATEMENT_ID CARDINALIT...
Case: incorrect low/high value<br />
SELECT count('1') RECCOUNT<br />	FROM Test_ILM_INTERACTIONt0<br />	JOIN Test_ILM_INTERACTION_TYPEt1 ON t0.INTERACTION_TYP ...
---------------------------------------------------------------------+----------------<br />| Id  | Operation             ...
sys@CS2PRD> @descTestowner.Test_ilm_interaction<br />Column Name        NUM_DISTINCT    DENSITY  Low                  High...
select to_date(2455714,'J') max_date from dual;<br />MAX_DATE<br />-------------------<br />2011-06-01 00:00:00<br />10053...
Solution:dbms_stats.set_colum_stats<br />m_high := ADD_MONTHS(m_high, 1);<br />m_val_array := DBMS_STATS.DATEARRAY(m_low, ...
sys@CS2PRD> @descTestowner.Test_ilm_interaction<br />Column Name        NUM_DISTINCT    DENSITY  Low                  High...
---------------------------------------------------------------------------------------------<br />| Id  | Operation      ...
select to_date(2455744,'J') max_date from dual;<br />MAX_DATE<br />-------------------<br />2011-07-01 00:00:00<br />10053...
Performance after tuning<br />
The functional scripts<br />
ThanksQ&A<br />
---------------------------------------------------------------------+----------------<br />| Id  | Operation             ...
B-tree Access Cost<br />cost =<br />blevel +<br />ceiling(leaf_blocks * effective index selectivity) +<br />ceiling(cluste...
Index Stats::<br />  Index: Test_ILM_INTERACTION_IDX3  Col#: 4 10 2 9 7 1<br />    LVLS: 3  #LB: 800771  #DK: 51629818  LB...
Index Stats::<br />  Index: Test_ILM_INTERACTION_REF_IDX1  Col#: 2 3<br />    LVLS: 3  #LB: 872428  #DK: 10567436  LB/K: 1...
Upcoming SlideShare
Loading in …5
×

CBO Basics: Cardinality

2,173 views

Published on

Published in: Business, Technology
  • Be the first to comment

CBO Basics: Cardinality

  1. 1. CBO Basics: Cardinality<br />Sidney Chen@zha-dba<br />
  2. 2. Agenda<br />Cardinality<br />The Cardinality under Various Prediction<br />Case study: incorrect high value<br />
  3. 3. Cardinality<br />The estimated number of rows <br />a query is expected to return.<br />Number of rows in table<br />x<br />Predicate selectivity<br />
  4. 4. Imaging there are 1200 people attend the dba weekly meeting, <br />They are randomly born in 12 month and comes from 10 citites, given the data the even distributed.<br />create table audience as<br />select<br /> mod(rownum-1,12) + 1 month_no,<br /> mod(rownum-1,10) + 1 city_no<br />from<br />all_objects<br />where<br />rownum <= 1200;<br />
  5. 5. sid@CS10G> select month_no, count(*) from audience group by month_no order by month_no;<br /> MONTH_NO COUNT(*)<br />---------- ----------<br /> 1 100<br /> 2 100<br /> 3 100<br /> 4 100<br /> 5 100<br /> 6 100<br /> 7 100<br /> 8 100<br /> 9 100<br /> 10 100<br /> 11 100<br /> 12 100<br />12 rows selected.<br />
  6. 6. sid@CS10G> select city_no, count(*) from audience group by city_no order by city_no;<br /> CITY_NO COUNT(*)<br />---------- ----------<br /> 1 120<br /> 2 120<br /> 3 120<br /> 4 120<br /> 5 120<br /> 6 120<br /> 7 120<br /> 8 120<br /> 9 120<br /> 10 120<br />10 rows selected.<br />
  7. 7. sid@CS10G> @indsid.audience;<br />OWNER TABLE_NAME BLOCKS NUM_ROWS AVG_ROW_LEN<br />----- ---------- ---------- ---------- -----------<br />SID AUDIENCE 5 1200 6<br />sid@CS10G> @descsid.audience;<br />Column Name NUM_DISTINCT DENSITY NUM_BUCKETS Low High<br />------------ ------------ ---------- ----------- ---- ----<br />MONTH_NO 12 .083333333 1 1 12<br />CITY_NO 10 .1 1 1 10<br />
  8. 8. Critical info<br />NDK: number of distinct keys<br /> Density = 1/NDK, (0.1 = 1/10) (0.083333333 = 1/12)<br />NUM_BUCKETS=1, there is no histogram gather<br />NUM_BUCKETS > 1, histogram gathered<br />
  9. 9. select month_no from audience where month_no=12;<br />Cardinality<br />1200 * (1/12) = 100<br />
  10. 10. sid@CS10G> select month_no from audience where month_no=12;<br />100 rows selected.<br />Execution Plan<br />----------------------------------------------------------<br />Plan hash value: 2423062965<br />-------------------------------------------------------------------<br />| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|<br />-------------------------------------------------------------------<br />| 0 | SELECT STATEMENT | | 100 | 300 | 3 (0)|<br />|* 1 | TABLE ACCESS FULL| AUDIENCE | 100 | 300 | 3 (0)|<br />-------------------------------------------------------------------<br />Predicate Information (identified by operation id):<br />---------------------------------------------------<br /> 1 - filter("MONTH_NO"=12)<br />
  11. 11. select month_no from audience where city_no=1;<br />Cardinality<br />1200 * (1/10) = 120<br />
  12. 12. sid@CS10G> select month_no from audience where city_no=1;<br />120 rows selected.<br />Execution Plan<br />----------------------------------------------------------<br />Plan hash value: 2423062965<br />-------------------------------------------------------------------<br />| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|<br />-------------------------------------------------------------------<br />| 0 | SELECT STATEMENT | | 120 | 720 | 3 (0)|<br />|* 1 | TABLE ACCESS FULL| AUDIENCE | 120 | 720 | 3 (0)|<br />-------------------------------------------------------------------<br />Predicate Information (identified by operation id):<br />---------------------------------------------------<br /> 1 - filter("CITY_NO"=1)<br />
  13. 13. select month_no from audience where month_no > 9;<br />Cardinality<br />1200 * ( (12-9)/(12-1) ) = 327<br />
  14. 14. sid@CS10G> select month_no from audience where month_no > 9;<br />300 rows selected.<br />Execution Plan<br />----------------------------------------------------------<br />Plan hash value: 2423062965<br />-------------------------------------------------------------------<br />| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|<br />-------------------------------------------------------------------<br />| 0 | SELECT STATEMENT | | 327 | 981 | 3 (0)|<br />|* 1 | TABLE ACCESS FULL| AUDIENCE | 327 | 981 | 3 (0)|<br />-------------------------------------------------------------------<br />Predicate Information (identified by operation id):<br />---------------------------------------------------<br /> 1 - filter("MONTH_NO">9)<br />
  15. 15. Equality: If Out of range<br />explain plan set statement_id = '12' for select month_no from audience where month_no = 12;<br />explain plan set statement_id = '13' for select month_no from audience where month_no = 13;<br />explain plan set statement_id = '14' for select month_no from audience where month_no = 14;<br />explain plan set statement_id = '15' for select month_no from audience where month_no = 15;<br />explain plan set statement_id = '16' for select month_no from audience where month_no = 16;<br />explain plan set statement_id = '17' for select month_no from audience where month_no = 17;<br />explain plan set statement_id = '18' for select month_no from audience where month_no = 18;<br />explain plan set statement_id = '19' for select month_no from audience where month_no = 19;<br />explain plan set statement_id = '20' for select month_no from audience where month_no = 20;<br />
  16. 16. sid@CS10G> select statement_id, cardinality from plan_table where id=1 order by statement_id;<br />STATEMENT_ID CARDINALITY<br />------------ -----------<br />12 100<br />13 91<br />14 82<br />15 73<br />1664<br />17 55<br />18 45<br />19 36<br />20 27<br />9 rows selected.<br />
  17. 17. Range: If Out of range<br />explain plan set statement_id = '12' for select month_no from audience where month_no > 12;<br />explain plan set statement_id = '13' for select month_no from audience where month_no > 13;<br />explain plan set statement_id = '14' for select month_no from audience where month_no > 14;<br />explain plan set statement_id = '15' for select month_no from audience where month_no > 15;<br />explain plan set statement_id = '16' for select month_no from audience where month_no > 16;<br />explain plan set statement_id = '17' for select month_no from audience where month_no > 17;<br />explain plan set statement_id = '18' for select month_no from audience where month_no > 18;<br />explain plan set statement_id = '19' for select month_no from audience where month_no > 19;<br />explain plan set statement_id = '20' for select month_no from audience where month_no > 20;<br />
  18. 18. sid@CS10G> select statement_id, cardinality from plan_table where id=1 order by statement_id;<br />STATEMENT_ID CARDINALITY<br />------------ -----------<br />12 100<br />13 91<br />14 82<br />15 73<br />1664<br />17 55<br />18 45<br />19 36<br />20 27<br />9 rows selected.<br />
  19. 19. The far from low/high range, the less you are to find data<br />
  20. 20. Bad news<br />If you have sequence, or time-based column in predicate(such as last modified date:last_mod_dt), and haven’t been keeping the statistics up to date<br />The Cardinality will drop as time passes, if you using equality and range on that column<br />
  21. 21. sid@CS10G> select month_no from audience where month_no > 16;<br />no rows selected<br />Execution Plan<br />----------------------------------------------------------<br />Plan hash value: 2423062965<br />-------------------------------------+-----------------------------------+<br />| Id | Operation | Name | Rows | Bytes | Cost | Time |<br />-------------------------------------+-----------------------------------+<br />| 0 | SELECT STATEMENT | | | | 3 | |<br />| 1 | TABLE ACCESS FULL | AUDIENCE| 64 | 192 | 3 | 00:00:01 |<br />-------------------------------------+-----------------------------------+<br />Predicate Information:<br />----------------------<br />1 - filter("MONTH_NO"=16)<br />
  22. 22. Using 10053 event to confirm<br />sid@CS10G> @53on<br />alter session set events '10053 trace name context forever, level 1';<br />Session altered.<br />sid@CS10G> explain plan for select month_no from audience where month_no > 16;<br />Explained.<br />sid@CS10G> @53off<br />sid@CS10G> @tracefile<br />TRACEFILE<br />----------------------------------------------------------------------------------------------------<br />/home/u02/app/oracle/product/11.1.0/db_1/admin/cs10g/udump/cs10g_ora_24947.trc<br />
  23. 23. SINGLE TABLE ACCESS PATH<br /> -----------------------------------------<br /> BEGIN Single Table Cardinality Estimation<br /> -----------------------------------------<br /> Column (#1): MONTH_NO(NUMBER)<br />AvgLen: 3.00 NDV: 12 Nulls: 0 Density: 0.083333 Min: 1 Max: 12<br />Using prorated density: 0.05303 of col #1 as selectivity of out-of-range value pred<br /> Table: AUDIENCE Alias: AUDIENCE<br /> Card: Original: 1200 Rounded: 64 Computed: 63.64 Non Adjusted: 63.64<br /> -----------------------------------------<br /> END Single Table Cardinality Estimation<br /> -----------------------------------------<br />
  24. 24. Between: If Out of range<br />explain plan set statement_id = '12' for select month_no from audience where month_nobetween 13 and 15;<br />explain plan set statement_id = '14' for select month_no from audience where month_nobetween 14 and 16; <br />explain plan set statement_id = '15' for select month_no from audience where month_nobetween 15 and 17; <br />explain plan set statement_id = '16' for select month_no from audience where month_no between 13 and 20; <br />explain plan set statement_id = '17' for select month_no from audience where month_no between 14 and 21; <br />explain plan set statement_id = '18' for select month_no from audience where month_no between 15 and 22; <br />explain plan set statement_id = '19' for select month_no from audience where month_no between 16 and 23;<br />
  25. 25. sid@CS10G> select statement_id, cardinality from plan_table where id=1 order by statement_id;<br />STATEMENT_ID CARDINALITY<br />------------ -----------<br />12 100<br />13 100<br />14 100<br />15 100<br />16 100<br />17 100<br />18 100<br />19 100<br />20 100<br />9 rows selected.<br />
  26. 26. Case: incorrect low/high value<br />
  27. 27. SELECT count('1') RECCOUNT<br /> FROM Test_ILM_INTERACTIONt0<br /> JOIN Test_ILM_INTERACTION_TYPEt1 ON t0.INTERACTION_TYP =<br /> t1.INTERACTION_TYP<br /> JOIN Test_ILM_INTERACTION_REFt3 ON t0.interaction_uuid =<br /> t3.interaction_uuid<br /> WHERE t1.IS_VIEWABLE = 1<br /> AND ((t0.DOMAIN_NME = 'DOMAIN_A') or<br /> (T0.DOMAIN_NME = 'DOMAIN_B' AND<br /> T0.APPLICATION_NME = 'APPLICATION_C'))<br /> AND (t3.REF_CDE = 'BK_NUMBER' AND t3.REF_KEY_VALUE = '2389301444')<br /> AND t0.INTERACTION_DT BETWEEN<br /> TO_DATE('01-06-2011 16:00:00', 'DD-MM-YYYY HH24:MI:SS') <br /> AND<br /> TO_DATE('16-06-2011 15:59:59', 'DD-MM-YYYY HH24:MI:SS')<br />
  28. 28. ---------------------------------------------------------------------+----------------<br />| Id | Operation | Name | Rows | Cost |<br />---------------------------------------------------------------------+----------------<br />| 0 | SELECT STATEMENT | | | 13 |<br />| 1 | SORT AGGREGATE | | 1 | |<br />| 2 | NESTED LOOPS | | 1 | 13 |<br />| 3 | NESTED LOOPS | | 1 | 12 |<br />| 4 | INDEX RANGE SCAN | Test_ILM_INTERACTION_IDX3 | 4 | 4 |<br />| 5 | INDEX UNIQUE SCAN | Test_ILM_INTERACTION_REF_PK| 1 | 2 |<br />| 6 | TABLE ACCESS BY INDEX ROWID | Test_ILM_INTERACTION_TYPE| 1 | 1 |<br />| 7 | INDEX UNIQUE SCAN | Test_ILM_INTERACTION_TYPE_PK| 1 | 0 |<br />---------------------------------------------------------------------+----------------<br />Predicate Information (identified by operation id):<br />---------------------------------------------------<br /> 4 - access("T0"."INTERACTION_DT">=TO_DATE('2011-06-01 05:00:00', 'yyyy-mm-dd hh24:mi:ss') AND<br /> "T0"."INTERACTION_DT"<=TO_DATE('2011-06-16 04:59:59', 'yyyy-mm-dd hh24:mi:ss'))<br /> filter("T0"."DOMAIN_NME"='DOMAIN_A' OR "T0"."APPLICATION_NME"='APPLICATION_C' AND<br /> "T0"."DOMAIN_NME"='DOMAIN_B')<br /> 5 - access("T0"."INTERACTION_UUID"="T3"."INTERACTION_UUID" AND "T3"."REF_CDE"='BL_NUMBER' AND<br /> "T3"."REF_KEY_VALUE"=2389301444')<br /> 6 - filter("T1"."IS_VIEWABLE"=1)<br /> 7 - access("T0"."INTERACTION_TYP"="T1"."INTERACTION_TYP")<br />
  29. 29. sys@CS2PRD> @descTestowner.Test_ilm_interaction<br />Column Name NUM_DISTINCT DENSITY Low High<br />------------------ ------------ ---------- -------------------- --------------------<br />INTERACTION_DT 7583898 1.3186E-07 2010-05-07 23:45:47 2011-05-31 15:31:35<br />sys@CS2PRD> @indTestowner.Test_ilm_interaction<br />TABLE_NAME INDEX_NAME POS# COLUMN_NAME <br />----------------------- --------------------------- ---- ----------------<br />Test_ILM_INTERACTION Test_ILM_INTERACTION_IDX3 1 INTERACTION_DT<br /> 2 COMPANY_ID<br /> 3 APPLICATION_NME<br /> 4 DOMAIN_NME<br /> 5 INTERACTION_TYP<br /> 6 INTERACTION_UUID<br />
  30. 30. select to_date(2455714,'J') max_date from dual;<br />MAX_DATE<br />-------------------<br />2011-06-01 00:00:00<br />10053 trace<br />Column (#4): INTERACTION_DT(DATE)<br />AvgLen: 8.00 NDV: 7583898 Nulls: 0 Density: 1.3186e-07 Min: 2455325 Max: 2455714<br />SINGLE TABLE ACCESS PATH<br /> Using prorated density: 1.3151e-07 of col#4 as selectivity of out-of-range value pred<br /> Table: Test_ILM_INTERACTIONAlias: T0<br /> Card: Original: 53138344 Rounded: 4 Computed: 3.75 Non Adjusted: 3.75<br /> Access Path: index (IndexOnly)<br /> Index: Test_ILM_INTERACTION_IDX3<br />resc_io: 4.00 resc_cpu: 29886<br />ix_sel: 1.3151e-07 ix_sel_with_filters: 7.0628e-08<br /> Cost: 4.00 Resp: 4.00 Degree: 1<br /> ****** trying bitmap/domain indexes ******<br /> Best:: AccessPath: IndexRange Index: Test_ILM_INTERACTION_IDX3<br /> Cost: 4.00 Degree: 1 Resp: 4.00 Card: 3.75 Bytes: 0<br />
  31. 31. Solution:dbms_stats.set_colum_stats<br />m_high := ADD_MONTHS(m_high, 1);<br />m_val_array := DBMS_STATS.DATEARRAY(m_low, m_high);<br />dbms_stats.prepare_column_values(<br />srec => m_statrec,<br />datevals => m_val_array<br /> );<br />dbms_stats.set_column_stats(<br />ownname => NULL,<br />tabname => '&&TABLE_NAME',<br />colname => '&&COLUMN_NAME', <br />distcnt => m_distcnt,<br /> density => m_density,<br />nullcnt => m_nullcnt,<br />srec => m_statrec,<br />avgclen => m_avgclen,<br />no_invalidate => false<br /> ); <br />Pls check the hack_stats_3.sql for the full script<br />
  32. 32. sys@CS2PRD> @descTestowner.Test_ilm_interaction<br />Column Name NUM_DISTINCT DENSITY Low High<br />------------------ ------------ ---------- -------------------- --------------------<br />INTERACTION_DT 7583898 1.3186E-07 2010-05-07 23:45:47 2011-06-31 15:31:35<br />
  33. 33. ---------------------------------------------------------------------------------------------<br />| Id | Operation | Name | Rows | Cost (%CPU)|<br />---------------------------------------------------------------------------------------------<br />| 0 | SELECT STATEMENT | | 1 | 14 (0)|<br />| 1 | SORT AGGREGATE | | 1 | |<br />| 2 | NESTED LOOPS | | 1 | 14 (0)|<br />| 3 | NESTED LOOPS | | 1 | 13 (0)|<br />| 4 | TABLE ACCESS BY INDEX ROWID| Test_ILM_INTERACTION_REF| 1 | 10 (0)|<br />|* 5 | INDEX RANGE SCAN | Test_ILM_INTERACTION_REF_IDX1 | 9 | 4 (0)|<br />|* 6 | TABLE ACCESS BY INDEX ROWID| Test_ILM_INTERACTION| 1 | 3 (0)|<br />|* 7 | INDEX UNIQUE SCAN | Test_ILM_INTERACTION_PK| 1 | 2 (0)|<br />|* 8 | TABLE ACCESS BY INDEX ROWID | Test_ILM_INTERACTION_TYPE| 1 | 1 (0)|<br />|* 9 | INDEX UNIQUE SCAN | Test_ILM_INTERACTION_TYPE_PK| 1 | 0 (0)|<br />---------------------------------------------------------------------------------------------<br />Predicate Information (identified by operation id):<br />---------------------------------------------------<br />5 - access("T3"."REF_CDE"='BK_NUMBER' AND "T3"."REF_KEY_VALUE"='2389301444')<br /> 6 - filter("T0"."INTERACTION_DT">=TO_DATE('2011-06-01 16:00:00', 'yyyy-mm-dd hh24:mi:ss') AND<br /> ("T0"."DOMAIN_NME"='DOMAIN_A' OR "T0"."APPLICATION_NME"='APPLICATION_C' AND<br /> "T0"."DOMAIN_NME"='DOMAIN_B') AND "T0"."INTERACTION_DT"<=TO_DATE('2011-06-16 15:59:59', 'yyyy-mm-dd<br /> hh24:mi:ss'))<br /> 7 - access("T0"."INTERACTION_UUID"="T3"."INTERACTION_UUID")<br /> 8 - filter("T1"."IS_VIEWABLE"=1)<br /> 9 - access("T0"."INTERACTION_TYP"="T1"."INTERACTION_TYP")<br />
  34. 34. select to_date(2455744,'J') max_date from dual;<br />MAX_DATE<br />-------------------<br />2011-07-01 00:00:00<br />10053 trace<br />***************************************<br /> SINGLE TABLE ACCESS PATH<br /> Column (#9): DOMAIN_NME(VARCHAR2)<br />AvgLen: 12.00 NDV: 10 Nulls: 53692 Density: 9.3545e-09<br /> Histogram: Freq #Bkts: 10 UncompBkts: 5973 EndPtVals: 10<br /> Column (#2): APPLICATION_NME(VARCHAR2)<br />AvgLen: 17.00 NDV: 30 Nulls: 0 Density: 9.3451e-09<br /> Histogram: Freq #Bkts: 30 UncompBkts: 5979 EndPtVals: 30<br /> Column (#4): INTERACTION_DT(DATE)<br />AvgLen: 8.00 NDV: 7583898 Nulls: 0 Density: 1.3186e-07 Min: 2455325 Max: 2455744<br /> Table: Test_ILM_INTERACTIONAlias: T0<br /> Card: Original: 53138344 Rounded: 1024006 Computed: 1024006.31 Non Adjusted: 1024006.31<br /> Access Path: index (IndexOnly)<br /> Index: Test_ILM_INTERACTION_IDX3<br />resc_io: 28694.00 resc_cpu: 574312799<br />ix_sel: 0.035829 ix_sel_with_filters: 0.019271<br /> Cost: 28722.69 Resp: 28722.69 Degree: 1<br /> ****** trying bitmap/domain indexes ******<br /> Best:: AccessPath: IndexRange Index: Test_ILM_INTERACTION_IDX3<br /> Cost: 28722.69 Degree: 1 Resp: 28722.69 Card: 1024006.31 Bytes: 0<br />***************************************<br />
  35. 35. Performance after tuning<br />
  36. 36. The functional scripts<br />
  37. 37. ThanksQ&A<br />
  38. 38. ---------------------------------------------------------------------+----------------<br />| Id | Operation | Name | Rows | Cost |<br />---------------------------------------------------------------------+----------------<br />| 0 | SELECT STATEMENT | | | 13 |<br />| 1 | SORT AGGREGATE | | 1 | |<br />| 2 | NESTED LOOPS | | 1 | 13 |<br />| 3 | NESTED LOOPS | | 1 | 12 |<br />| 4 | INDEX RANGE SCAN | Test_ILM_INTERACTION_IDX3 | 4 | 4 |<br />| 5 | INDEX UNIQUE SCAN | Test_ILM_INTERACTION_REF_PK| 1 | 2 |<br />| 6 | TABLE ACCESS BY INDEX ROWID | Test_ILM_INTERACTION_TYPE| 1 | 1 |<br />| 7 | INDEX UNIQUE SCAN | Test_ILM_INTERACTION_TYPE_PK| 1 | 0 |<br />---------------------------------------------------------------------+----------------<br />---------------------------------------------------------------------------------------------<br />| Id | Operation | Name | Rows | Cost (%CPU)|<br />---------------------------------------------------------------------------------------------<br />| 0 | SELECT STATEMENT | | 1 | 14 (0)|<br />| 1 | SORT AGGREGATE | | 1 | |<br />| 2 | NESTED LOOPS | | 1 | 14 (0)|<br />| 3 | NESTED LOOPS | | 1 | 13 (0)|<br />| 4 | TABLE ACCESS BY INDEX ROWID| Test_ILM_INTERACTION_REF| 1 | 10 (0)|<br />|* 5 | INDEX RANGE SCAN | Test_ILM_INTERACTION_REF_IDX1 | 9 | 4 (0)|<br />|* 6 | TABLE ACCESS BY INDEX ROWID| Test_ILM_INTERACTION| 1 | 3 (0)|<br />|* 7 | INDEX UNIQUE SCAN | Test_ILM_INTERACTION_PK| 1 | 2 (0)|<br />|* 8 | TABLE ACCESS BY INDEX ROWID | Test_ILM_INTERACTION_TYPE| 1 | 1 (0)|<br />|* 9 | INDEX UNIQUE SCAN | Test_ILM_INTERACTION_TYPE_PK| 1 | 0 (0)|<br />---------------------------------------------------------------------------------------------<br />
  39. 39. B-tree Access Cost<br />cost =<br />blevel +<br />ceiling(leaf_blocks * effective index selectivity) +<br />ceiling(clustering_factor * effective table selectivity)<br /> = <br />blevel +<br />ceiling(leaf_blocks * ix_sel)+<br />ceiling(clustering_factor *ix_sel_with_filter)<br />
  40. 40. Index Stats::<br /> Index: Test_ILM_INTERACTION_IDX3 Col#: 4 10 2 9 7 1<br /> LVLS: 3 #LB: 800771 #DK: 51629818 LB/K: 1.00 DB/K: 1.00 CLUF: 27495746.00<br /> Access Path: index (IndexOnly)<br /> Index: Test_ILM_INTERACTION_IDX3<br />resc_io: 4.00 resc_cpu: 29886<br />ix_sel: 1.3151e-07 ix_sel_with_filters: 7.0734e-08<br /> Cost: 4.00 Resp: 4.00 Degree: 1<br />sys@CS10G> select 3 + ceil(800771 * 0.00000013151) cost from dual;<br /> COST<br />----------<br /> 4<br />Index only, no need to access table<br />
  41. 41. Index Stats::<br /> Index: Test_ILM_INTERACTION_REF_IDX1 Col#: 2 3<br /> LVLS: 3 #LB: 872428 #DK: 10567436 LB/K: 1.00 DB/K: 5.00 CLUF: 60057635.00<br /> Access Path: index (AllEqRange)<br /> Index: Test_ILM_INTERACTION_REF_IDX1<br />resc_io: 10.00 resc_cpu: 74724<br />ix_sel: 9.4630e-08 ix_sel_with_filters: 9.4630e-08<br /> Cost: 10.00 Resp: 10.00 Degree: 1<br />sys@CS10G> select 3 + ceil(872428 * 0.00000009463) + ceil(60057535 * 0.00000009463) cost from dual;<br /> COST<br />----------<br />10<br />

×