major to introduce advanced usage of dbms_stats for CG(column group ) of extened statistics. We start this test on oracle 11.2.0.3 oel5.8 64bit : Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> show user USER is "TEST" SQL> CREATE TABLE sampletable( id NUMBER,
test/test Connected. SQL> EXPLAIN PLAN FOR SELECT * FROM sampletable WHERE city = 'Madrid'; Explained. SQL> SELECT PLAN_TABLE_OUTPUT FROM TABLE(DBMS_XPLAN.DISPLAY( format => 'ALLSTATS' )); PLAN_TABLE_OUTPUT ------------------------------------------------------------------------------------------------------------------------------------------------------------------
Note ----- - Warning: basic plan statistics not available. These are only collected when: * hint 'gather_plan_statistics' is used for the statement or * parameter 'statistics_level' is set to 'ALL', at session or system level 19 rows selected.
FROM sampletable WHERE country = 'Spain'; Explained. SQL> SELECT PLAN_TABLE_OUTPUT FROM TABLE(DBMS_XPLAN.DISPLAY( format => 'ALLSTATS' )); PLAN_TABLE_OUTPUT ------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------ Plan hash value: 2813936524 --------------------------------------------------
Warning: basic plan statistics not available. These are only collected when: * hint 'gather_plan_statistics' is used for the statement or * parameter 'statistics_level' is set to 'ALL', at session or system level 19 rows selected.
5 minutes or 300 seconds SQL> begin 2 dbms_stats.seed_col_usage(null,null,300); 3 end; 4 / PL/SQL procedure successfully completed. SQL> EXPLAIN PLAN FOR SELECT * FROM sampletable WHERE city = 'Madrid' and country = 'Spain'; Explained.
--------------------------------------------------- PLAN_TABLE_OUTPUT ------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------ 1 - filter("CITY"='Madrid' AND "COUNTRY"='Spain') Note ----- - Warning: basic plan statistics not available. These are only collected when:
the statement or * parameter 'statistics_level' is set to 'ALL', at session or system level 19 rows selected. SQL> set long 90000 SQL> set lines 2000 SQL> set pages 500 SQL> select dbms_stats.report_col_usage('TEST','SAMPLETABLE') from dual; DBMS_STATS.REPORT_COL_USAGE('TEST','SAMPLETABLE') -------------------------------------------------------------------------------- LEGEND:
table EQuality predicate RANGE : Used in single table RANGE predicate LIKE : Used in single table LIKE predicate NULL : Used in single table is (not) NULL predicate EQ_JOIN : Used in EQuality JOIN predicate NONEQ_JOIN : Used in NON EQuality JOIN predicate FILTER : Used in single table FILTER predicate JOIN : Used in JOIN predicate GROUP_BY : Used in GROUP BY expression ...............................................................................
HOTELNAME 6 4.3847E+35 CITY 1 3.4467E+35 CITY 3 4.0178E+35 CITY 5 4.0706E+35 CITY 6 4.2803E+35 COUNTRY 1 3.8140E+35 COUNTRY 4 4.3324E+35 COUNTRY 6 4.4303E+35 19 rows selected.
FOR SELECT * FROM sampletable WHERE country = 'Spain' and city = 'Madrid' ; Explained. SQL> SELECT PLAN_TABLE_OUTPUT FROM TABLE(DBMS_XPLAN.DISPLAY( format => 'ALLSTATS' )); PLAN_TABLE_OUTPUT ------------------------------------------------------------------------------------------------------------------------------------------------------------------ -------------------------------------- Plan hash value: 2813936524
Note ----- - Warning: basic plan statistics not available. These are only collected when: * hint 'gather_plan_statistics' is used for the statement or * parameter 'statistics_level' is set to 'ALL', at session or system level 19 rows selected.
of these two columns. SQL> conn /as sysdba Connected. SQL> oradebug setmypid Statement processed. SQL> oradebug unlimit Statement processed. SQL> oradebug event 10053 trace name context forever, level 1 Statement processed. SQL> SQL> EXPLAIN PLAN FOR SELECT * FROM TEST.sampletable WHERE country = 'Spain' and city = 'Madrid' ;