|
- 索引的使用监控:
- [oracle@station90 ~]$ sqlplus /nolog
- SQL*Plus: Release 11.2.0.3.0 Production on Sun Dec 3 15:26:29 2017
- Copyright (c) 1982, 2011, Oracle. All rights reserved.
- SQL> conn hr/oracle_4U
- Connected.
- SQL> select index_name from user_indexes where table_name='T_BIG';
- no rows selected
- SQL> conn / as sysdba
- Connected.
- SQL> create table hr.t_big as select * from dba_source;
- Table created.
- SQL> conn hr/oracle_4U
- Connected.
- SQL> create bitmap index i_big on t_big ( type ) ;
- Index created.
- SQL> alter index i_big monitoring usage;
- Index altered.
- SQL> select type , count(*) from t_big group by type where type in ( 'PACKAGE', 'PACKAGE BODY') ;
- select type , count(*) from t_big group by type where type in ( 'PACKAGE', 'PACKAGE BODY')
- *
- ERROR at line 1:
- ORA-00933: SQL command not properly ended
- SQL> select type , count(*) from t_big where type in ( 'PACKAGE', 'PACKAGE BODY') group by type ;
- TYPE COUNT(*)
- ------------ ----------
- PACKAGE 228607
- PACKAGE BODY 344031
- SQL> set autot on
- SQL> select type , count(*) from t_big where type in ( 'PACKAGE', 'PACKAGE BODY') group by type ;
- TYPE COUNT(*)
- ------------ ----------
- PACKAGE BODY 344031
- PACKAGE 228607
- Execution Plan
- ----------------------------------------------------------
- Plan hash value: 3148276265
- --------------------------------------------------------------------------------
- -------
- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Tim
- e |
- --------------------------------------------------------------------------------
- -------
- | 0 | SELECT STATEMENT | | 551K| 4306K| 36 (45)| 00:
- 00:01 |
- | 1 | HASH GROUP BY | | 551K| 4306K| 36 (45)| 00:
- 00:01 |
- | 2 | BITMAP CONVERSION COUNT | | 551K| 4306K| 20 (0)| 00:
- 00:01 |
- |* 3 | BITMAP INDEX FAST FULL SCAN| I_BIG | | | |
- |
- --------------------------------------------------------------------------------
- -------
- Predicate Information (identified by operation id):
- ---------------------------------------------------
- 3 - filter("TYPE"='PACKAGE' OR "TYPE"='PACKAGE BODY')
- Note
- -----
- - dynamic sampling used for this statement (level=2)
- Statistics
- ----------------------------------------------------------
- 0 recursive calls
- 0 db block gets
- 22 consistent gets
- 0 physical reads
- 0 redo size
- 671 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)
- 2 rows processed
- SQL> select * from v$object_usage;
- INDEX_NAME TABLE_NAME MON USE
- ------------------------------ ------------------------------ --- ---
- START_MONITORING END_MONITORING
- ------------------- -------------------
- I_BIG T_BIG YES YES
- 12/03/2017 15:31:36
- Execution Plan
- ----------------------------------------------------------
- ERROR:
- ORA-01039: insufficient privileges on underlying objects of the view
- SP2-0612: Error generating AUTOTRACE EXPLAIN report
- Statistics
- ----------------------------------------------------------
- 105 recursive calls
- 0 db block gets
- 55 consistent gets
- 0 physical reads
- 0 redo size
- 930 bytes sent via SQL*Net to client
- 520 bytes received via SQL*Net from client
- 2 SQL*Net roundtrips to/from client
- 8 sorts (memory)
- 0 sorts (disk)
- 1 rows processed
- SQL>
- --------------------------------------------------
- create table iot1 ( a number , b varchar2(200 ) , constraint
- pk_iot1 primary key ( a ))
- organization index
- pctthreshold 10
- overflow tablespace users
- ;
- ----
- create table iot1 ( a number , b varchar2(200 ) , constraint
- pk_iot1 primary key ( a ))
- organization index
- pctthreshold 10
- overflow tablespace users
- ;
- select * from dba_objects o where o.OWNER='HR'
- and o.OBJECT_NAME='IOT1';
-
- select * from dba_tables t where t.TABLE_NAME like '%80694%';
- select * from SYS_IOT_OVER_80694;
- select * from SYS_IOT_MAP_80694;
- alter table iot1 move mapping table;
- insert into iot1 values ( 1 ,'AAAA') ;
- -------------------
- select spid from
- v$session s , v$process p
- where s.PADDR=p.ADDR
- and s.terminal='pts/1';
- ---------
复制代码- select spid from
- v$session s , v$process p
- where s.PADDR=p.ADDR
- and s.terminal='pts/1';
-
- ---------------------
- SELECT s.sid, s.serial#, p.spid as "OS PID",s.username,
- s.module, st.value/100 as "CPU sec"
- FROM v$sesstat st, v$statname sn, v$session s, v$process p
- WHERE sn.name = 'CPU used by this session'
- AND st.statistic# = sn.statistic#
- AND st.sid = s.sid
- AND s.paddr = p.addr
- AND s.last_call_et < 1800
- AND s.logon_time > (SYSDATE - 240/1440)
- ORDER BY st.value;
- ---------------
- select * from v$session_event ;
- ---------------------
- SELECT s.sid, s.serial#, p.spid as "OS PID", s.username,
- s.module, se.time_waited
- FROM v$session_event se, v$session s, v$process p
- WHERE se.event = '&event_name'
- AND s.last_call_et < 1800
- AND s.logon_time > (SYSDATE - 240/1440)
- AND se.sid = s.sid
- AND s.paddr = p.addr
- ORDER BY se.time_waited;
- ------
- SELECT s.sid, s.serial#, p.spid as "OS PID", s.username,
- s.module, st.value/100 as "DB Time (sec)",
- stcpu.value/100 as "CPU Time (sec)",
- round(stcpu.value / st.value * 100,2) as "%CPU"
- FROM v$sesstat st, v$statname sn, v$session s,
- v$sesstat stcpu, v$statname sncpu, v$process p
- WHERE sn.name = 'DB time'
- AND st.statistic# = sn.statistic#
- AND st.sid = s.sid
- AND sncpu.name = 'CPU used by this session'
- AND stcpu.statistic# = sncpu.statistic#
- AND stcpu.sid = st.sid
- AND s.paddr = p.addr
- AND s.last_call_et < 1800
- AND s.logon_time > (SYSDATE - 240/1440)
- AND st.value > 0;
- ------
复制代码
最后一条语句,可以代替图形界面找顶级SQL:
- SQL> exec dbms_application_info.set_module ( 'GL','Asset_Cal' ) ;
- PL/SQL procedure successfully completed.
- SQL> select count(*) from t_big a , t_big b;
复制代码- [oracle@station90 ~]$ sqlplus /nolog
- SQL*Plus: Release 11.2.0.3.0 Production on Sun Dec 3 17:43:20 2017
- Copyright (c) 1982, 2011, Oracle. All rights reserved.
- SQL> conn hr/oracle_4U
- Connected.
- SQL> exec dbms_application_info.set_module ( 'GL','Asset_Cal' ) ;
- PL/SQL procedure successfully completed.
- SQL> select count(*) from t04209_uname a , t04209_uname b;
复制代码 这个不会被跟踪:
- [oracle@station90 ~]$ sqlplus /nolog
- SQL*Plus: Release 11.2.0.3.0 Production on Sun Dec 3 17:43:58 2017
- Copyright (c) 1982, 2011, Oracle. All rights reserved.
- SQL> conn hr/oracle_4U
- Connected.
- SQL> select count(*) from t04209_uname a , t_big b;
复制代码
进行端对端跟踪,必备trcsess这个工具。
|
|