|
- select * from dba_advisor_sqlplans;
- select count(*) from hr.plan_table;
- insert into hr.plan_table (statement_id,plan_id,timestamp,remarks,OPERATION,OPTIONS,OBJECT_NODE,OBJECT_OWNER,OBJECT_NAME,OBJECT_ALIAS,OBJECT_INSTANCE,OBJECT_TYPE,OPTIMIZER,SEARCH_COLUMNS,ID,PARENT_ID,DEPTH,POSITION,COST,CARDINALITY,BYTES,OTHER_TAG,PARTITION_START,PARTITION_STOP,PARTITION_ID,DISTRIBUTION,CPU_COST,IO_COST,TEMP_SPACE,ACCESS_PREDICATES,FILTER_PREDICATES,PROJECTION,TIME,QBLOCK_NAME,OTHER_XML
- )
- select statement_id,plan_id,timestamp,remarks,OPERATION,OPTIONS,OBJECT_NODE,OBJECT_OWNER,OBJECT_NAME,OBJECT_ALIAS,OBJECT_INSTANCE,OBJECT_TYPE,OPTIMIZER,SEARCH_COLUMNS,ID,PARENT_ID,DEPTH,POSITION,COST,CARDINALITY,BYTES,OTHER_TAG,PARTITION_START,PARTITION_STOP,PARTITION_ID,DISTRIBUTION,CPU_COST,IO_COST,TEMP_SPACE,ACCESS_PREDICATES,FILTER_PREDICATES,PROJECTION,TIME,QBLOCK_NAME,OTHER_XML
- from DBA_ADVISOR_SQLPLANS ;
- commit;
复制代码- select * from plan_table1;
- truncate table plan_table1;
- select id, lpad(' ', depth)|| operation operation,
- options, object_name, optimizer ,cost
- from hr.plan_table1 p
- start with id=0
- connect by prior id= parent_id
- ;
-
- select id, lpad(' ', depth)|| operation operation,
- options, object_name, optimizer ,cost,cardinality,time,qblock_name
- from v$sql_plan
- where hash_value='2776053402'
- and address='00000001ED882F38'
- start with id=0
- connect by ( prior id= parent_id
- and prior hash_value=hash_value
- and prior child_number=child_number
- )
- ;
-
- select s.HASH_VALUE, s.ADDRESS , s.SQL_FULLTEXT from v_$sql s
- where s.SQL_FULLTEXT like '%employees%departments%';
-
-
-
复制代码- select s.HASH_VALUE, s.ADDRESS , s.SQL_FULLTEXT,s.SQL_ID from v_$sql s
- where s.SQL_FULLTEXT like '%employees%departments%';
-
- select * from table(dbms_xplan.display_cursor('cfz0cdukrfdnu',
- format => 'ADVANCED +ALIAS'));
复制代码- select * from v$sql_plan
- where sql_id='99qa3zyarxvms';
- select * from table(dbms_xplan.display_awr('99qa3zyarxvms',
- format => 'ADVANCED +ALIAS'));
复制代码- SQL> ed
- Wrote file afiedt.buf
- 1 SELECT /*+ USE_HASH(e,d) leading(e) */
- 2 d.deptno,d.dname,e.empno,e.ename
- 3 FROM
- 4 emp e, dept d
- 5* WHERE e.deptno(+)=d.deptno
- SQL> /
- DEPTNO DNAME EMPNO ENAME
- ---------- -------------- ---------- ----------
- 20 RESEARCH 7369 SMITH
- 30 SALES 7499 ALLEN
- 30 SALES 7521 WARD
- 20 RESEARCH 7566 JONES
- 30 SALES 7654 MARTIN
- 30 SALES 7698 BLAKE
- 10 ACCOUNTING 7782 CLARK
- 20 RESEARCH 7788 SCOTT
- 10 ACCOUNTING 7839 KING
- 30 SALES 7844 TURNER
- 20 RESEARCH 7876 ADAMS
- DEPTNO DNAME EMPNO ENAME
- ---------- -------------- ---------- ----------
- 30 SALES 7900 JAMES
- 20 RESEARCH 7902 FORD
- 10 ACCOUNTING 7934 MILLER
- 40 OPERATIONS
- 15 rows selected.
- Execution Plan
- ----------------------------------------------------------
- Plan hash value: 3713469723
- ---------------------------------------------------------------------------
- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
- ---------------------------------------------------------------------------
- | 0 | SELECT STATEMENT | | 14 | 364 | 7 (15)| 00:00:01 |
- |* 1 | HASH JOIN OUTER | | 14 | 364 | 7 (15)| 00:00:01 |
- | 2 | TABLE ACCESS FULL| DEPT | 4 | 52 | 3 (0)| 00:00:01 |
- | 3 | TABLE ACCESS FULL| EMP | 14 | 182 | 3 (0)| 00:00:01 |
- ---------------------------------------------------------------------------
- Predicate Information (identified by operation id):
- ---------------------------------------------------
- 1 - access("E"."DEPTNO"(+)="D"."DEPTNO")
- Statistics
- ----------------------------------------------------------
- 8 recursive calls
- 0 db block gets
- 15 consistent gets
- 0 physical reads
- 0 redo size
- 1137 bytes sent via SQL*Net to client
- 520 bytes received via SQL*Net from client
- 2 SQL*Net roundtrips to/from client
- 0 sorts (memory)
- 0 sorts (disk)
- 15 rows processed
- SQL> ed
- Wrote file afiedt.buf
- 1 SELECT /*+ USE_HASH(e,d) leading(e) */
- 2 d.deptno,d.dname,e.empno,e.ename
- 3 FROM
- 4 emp e, dept d
- 5* WHERE e.deptno=d.deptno
- SQL> /
- DEPTNO DNAME EMPNO ENAME
- ---------- -------------- ---------- ----------
- 10 ACCOUNTING 7934 MILLER
- 10 ACCOUNTING 7839 KING
- 10 ACCOUNTING 7782 CLARK
- 20 RESEARCH 7902 FORD
- 20 RESEARCH 7876 ADAMS
- 20 RESEARCH 7788 SCOTT
- 20 RESEARCH 7566 JONES
- 20 RESEARCH 7369 SMITH
- 30 SALES 7900 JAMES
- 30 SALES 7844 TURNER
- 30 SALES 7698 BLAKE
- DEPTNO DNAME EMPNO ENAME
- ---------- -------------- ---------- ----------
- 30 SALES 7654 MARTIN
- 30 SALES 7521 WARD
- 30 SALES 7499 ALLEN
- 14 rows selected.
- Execution Plan
- ----------------------------------------------------------
- Plan hash value: 1123238657
- ---------------------------------------------------------------------------
- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
- ---------------------------------------------------------------------------
- | 0 | SELECT STATEMENT | | 14 | 364 | 7 (15)| 00:00:01 |
- |* 1 | HASH JOIN | | 14 | 364 | 7 (15)| 00:00:01 |
- | 2 | TABLE ACCESS FULL| EMP | 14 | 182 | 3 (0)| 00:00:01 |
- | 3 | TABLE ACCESS FULL| DEPT | 4 | 52 | 3 (0)| 00:00:01 |
- ---------------------------------------------------------------------------
- Predicate Information (identified by operation id):
- ---------------------------------------------------
- 1 - access("E"."DEPTNO"="D"."DEPTNO")
- Statistics
- ----------------------------------------------------------
- 10 recursive calls
- 0 db block gets
- 16 consistent gets
- 0 physical reads
- 0 redo size
- 1051 bytes sent via SQL*Net to client
- 520 bytes received via SQL*Net from client
- 2 SQL*Net roundtrips to/from client
- 0 sorts (memory)
- 0 sorts (disk)
- 14 rows processed
- SQL>
复制代码- CREATE CLUSTER calls_cluster
- ( origin_number NUMBER
- , call_timestamp NUMBER SORT
- , call_duration NUMBER SORT)
- HASHKEYS 10000
- SINGLE TABLE HASH IS origin_number
- SIZE 50;
复制代码- CREATE TABLE calls
- ( origin_number NUMBER
- , call_timestamp NUMBER
- , call_duration NUMBER
- , other_info VARCHAR2(30))
- CLUSTER calls_cluster(
- origin_number,call_timestamp,call_duration
- );
复制代码
|
|