oracle性能问题如何定位

最近甲方抱怨,oracle 怎么越跑越慢,感觉没有做什么。

1.先整体看看 awr

oracle性能问题如何定位_第1张图片


哎,没有什么大问题。


2.再看看等待事件 ,读写数据量有点大,网络带宽是不是也有点问题?

unicomidmp@UNICOM>select * from (select event,total_waits,time_waited from v$system_event where wait_class!='Idle' order by 2 desc)
where rownum<=5;  2  

EVENT					 TOTAL_WAITS TIME_WAITED
---------------------------------------- ----------- -----------
SQL*Net message to client		   558958155	  280641
direct path write			    17125518	   60928
direct path read temp			    15348717	   94114
CGS wait for IPC msg			    12819270	   34251
row cache process			     3955634	    2093

unicomidmp@UNICOM>


3.再看看数据库中大于6s的所有操作 ,BIN$MqiYSgwmm1ngU8gcZAr/JQ==$0有点多,  是不是drop table 没有purge?  而且程序还在跑?

SQL> select opname,target,sql_hash_value,count(*) from v$session_longops group by opname,target,sql_hash_value;
 
OPNAME                                                           TARGET                                                           SQL_HASH_VALUE   COUNT(*)
---------------------------------------------------------------- ---------------------------------------------------------------- -------------- ----------
Table Scan                                                       UNICOMIDMP.S_CONF_UTRANCELL_LATEST                                     39128036          2
Table Scan                                                       UNICOMIDMP.USER_TERMINAL_INFO_PURED                                  3215935786          3
Table Scan                                                       UNICOMIDMP.S_CONF_UTRANCELL_LATEST                                   2796354940          1
Table Scan                                                       UNICOMIDMP.BIN$MqiYSgwmm1ngU8gcZAr/JQ==$0                             884600104          1
Table Scan                                                       UNICOMIDMP.BIN$Mp2OEx6spxngU8gcZAqrJQ==$0                              19670268          1
Table Scan                                                       UNICOMIDMP.BIN$Ms+JSeUhN/XgU8gcZAr6Ig==$0                            1268972253          1
Table Scan                                                       UNICOMIDMP.USER_TERMINAL_INFO_PURED_FLAG                             2830050620          1
SYS_EXPORT_SCHEMA_01                                                                                                                  2610655817          1
Table Scan                                                       UNICOMIDMP.BIN$Ms+JSeUtN/XgU8gcZAr6Ig==$0                            1777384970          1
Table Scan                                                       UNICOMIDMP.USER_TMP_POINT_IMEI_LABEL                                  850788924          1
Table Scan                                                       UNICOMIDMP.S_CONF_CELL_LATEST                                         752358244          1
Table Scan                                                       UNICOMIDMP.S_CONF_UTRANCELL_LATEST                                   3018082299          3
Table Scan                                                       UNICOMIDMP.S_CONF_ETRANCELL_LATEST                                    599191390          1
Table Scan                                                       UNICOMIDMP.S_CONF_ETRANCELL_LATEST                                   1556111901          1
Table Scan                                                       UNICOMIDMP.USER_TERMINAL_INFO_PURED                                  3785492571          1
Table Scan                                                       UNICOMIDMP.BIN$Ms+JSeUhN/XgU8gcZAr6Ig==$0                            3368282903          1
Table Scan                                                       UNICOMIDMP.BIN$Ms+JSeUtN/XgU8gcZAr6Ig==$0                             920334701          1
Table Scan                                                       UNICOMIDMP.S_CONF_UTRANCELL_LATEST                                   1464500089          1
Table Scan                                                       UNICOMIDMP.S_CONF_UTRANCELL_LATEST                                   3362048161          1
Table Scan                                                       UNICOMIDMP.BIN$Mpvl7k/gUqzgU8gcZArNLA==$0                            3883942665          1
 
OPNAME                                                           TARGET                                                           SQL_HASH_VALUE   COUNT(*)
---------------------------------------------------------------- ---------------------------------------------------------------- -------------- ----------
Table Scan                                                       UNICOMIDMP.S_CONF_ETRANCELL_LATEST                                   1542225309          1
Table Scan                                                       UNICOMIDMP.USER_DAY_LOCATION                                           10387713          1
Table Scan                                                       UNICOMIDMP.S_CONF_UTRANCELL_LATEST                                   4167064535         36
Table Scan                                                       MENGL.TEST_TAB                                                       3346715350          1
Table Scan                                                       UNICOMIDMP.BIN$MqiYSgwsm1ngU8gcZAr/JQ==$0                             884600104          1
Table Scan                                                       UNICOMIDMP.USER_TERMINAL_INFO_PURED                                   232981614          1
Table Scan                                                       UNICOMIDMP.BIN$Ms+JSeUhN/XgU8gcZAr6Ig==$0                            1904945350          1


--4.看看表有多大。

unicomidmp@UNICOM>select count(*) from USER_TMP_POINT_IMEI_LABEL;

  COUNT(*)
----------
  59310705

unicomidmp@UNICOM>


这个表这么大? 全表扫描? 什么业务? 分区了? 有索引? 存在高水位? 统计信息过期?

unicomidmp@UNICOM>select * from user_tab_partitions  where table_name ='USER_TMP_POINT_IMEI_LABEL';

no rows selected

unicomidmp@UNICOM>select * from user_ind_columns where table_name='USER_TMP_POINT_IMEI_LABEL';

no rows selected

unicomidmp@UNICOM>


--5..通过sql_hash_value ,定位到sql 看看,怎么回事。

unicomidmp@UNICOM>select sql_text from v$sqltext where hash_value=3215935786 order by address,piece;

SQL_TEXT
----------------------------------------------------------------
CREATE TABLE user_terminal_info_pured_flag AS SELECT	 month,
    imsi,     CASE WHEN net_type = '3G' THEN 1		WHEN net
_type = '2G' THEN 0	     END AS net_type,	  sex,	   termi
nal_brand,     terminal_model,	   CASE WHEN age_range = '??'
THEN 0		WHEN age_range = '17???' THEN 1 	 WHEN
 age_range = '18-22' THEN 2	     WHEN age_range = '23-25' TH
EN 3	      WHEN age_range = '26-29' THEN 4	       WHEN age_
range = '30-39' THEN 5		WHEN age_range = '40-49' THEN 6
	 WHEN age_range = '50-59' THEN 7	  WHEN age_range
 = '60??' THEN 8	  END AS age,	  CASE WHEN arpu_range
 = '0-49' THEN 1	  WHEN arpu_range = '50-99' THEN 2
    WHEN arpu_range = '100-149' THEN 3		WHEN arpu_range
= '150-199' THEN 4	    WHEN arpu_range = '200-249' THEN 5
	WHEN arpu_range = '250-299' THEN 6	    WHEN arpu_ra
nge = '300???' THEN 7	       END AS arpu,	CASE WHEN tra
ffic_usage = '0-499' THEN 1	     WHEN traffic_usage = '500-9
99' THEN 2	    WHEN traffic_usage = '1000-1499' THEN 3
     WHEN traffic_usage = '1500-1999' THEN 4	      WHEN traff
ic_usage = '2000-2499' THEN 5	       WHEN traffic_usage = '250
0-2999' THEN 6		WHEN traffic_usage = '3000-3499' THEN 7
	 WHEN traffic_usage = '3500-3999' THEN 8	  WHEN t
raffic_usage = '4000-4499' THEN 9	   WHEN traffic_usage =
'4500-4999' THEN 10	     WHEN traffic_usage = '5000??' THE
N 11	      END AS traffic,	  CASE WHEN voice_lens >= 0 AND
voice_lens < 120 THEN 1 	 WHEN voice_lens >= 120 AND voic
e_lens < 240 THEN 2	     WHEN voice_lens >= 240 AND voice_le
ns < 360 THEN 3 	 WHEN voice_lens >= 360 AND voice_lens <
 480 THEN 4	     WHEN voice_lens >= 480 AND voice_lens < 600
 THEN 5 	 WHEN voice_lens >= 600 AND voice_lens < 720 THE
N 6	     WHEN voice_lens >= 720 AND voice_lens < 840 THEN 7
	 WHEN voice_lens >= 840 AND voice_lens < 960 THEN 8
     WHEN voice_lens >= 960 AND voice_lens < 1080 THEN 9
  WHEN voice_lens >= 1080 AND voice_lens < 1200 THEN 10
 WHEN voice_lens >= 1200 THEN 11	  END AS voice,     CASE
 WHEN sms_num >= 0 AND sms_num < 20 THEN 1	    WHEN sms_num
 >= 20 AND sms_num < 40 THEN 2		WHEN sms_num >= 40 AND s
ms_num < 60 THEN 3	    WHEN sms_num >= 60 AND sms_num < 80
THEN 4		WHEN sms_num >= 80 AND sms_num < 100 THEN 5
     WHEN sms_num >= 100 AND sms_num < 120 THEN 6	   WHEN
sms_num >= 120 AND sms_num < 140 THEN 7 	 WHEN sms_num >=
 140 AND sms_num < 160 THEN 8	       WHEN sms_num >= 160 AND s
ms_num < 180 THEN 9	     WHEN sms_num >= 180 AND sms_num < 2
00 THEN 10	    WHEN sms_num >= 200 THEN 11 	 END AS
sms FROM user_terminal_info_pured

44 rows selected.

unicomidmp@UNICOM>

结果是一个单表的转换过程,  这个完全可以用视图代替,没有必要再生成一个实体表。 这样增加了读写量。


---依次类推, 我们这里还有很多条sql,  每条都拿出来分析,修改设计。 避免性能产生。



补充结构:

V$SESSION_LONGOPS列说明
SID:Session标识
SERIAL#:Session串号
OPNAME:操作简要说明
TARGET:操作运行所在的对象
TARGET_DESC:目标对象说明
SOFAR:至今为止完成的工作量
TOTALWORK:总工作量
UNITS:工作量单位
START_TIME:操作开始时间
LAST_UPDATE_TIME:统计项最后更新时间
TIME_REMAINING:预计完成操作的剩余时间(秒)
ELAPSED_SECONDS:从操作开始总花费时间(秒)
CONTEXT:前后关系
MESSAGE:统计项的完整描述
USERNAME:执行操作的用户ID
SQL_ADDRESS:用于连接查询的列
SQL_HASH_VALUE:用于连接查询的列
QCSID:




-------------

by  mengl

2016.5.19   end






你可能感兴趣的:(oracle_sql,tuning)