1、开启等待事件采集器
需要修改setup_instruments 配置表中对应的采集器配置项
update setup_instruments set ENABLED ='YES',TIMED='YES' where name like 'wait/%'
2、开启等待事件的保存表配置项
修改setup_consumers 配置表 中对应的配置项
update setup_consumers set ENABLED='YES' where name like '%wait%'
3、创建视图
create view sys.test_waits as
select sum(timer_wait) as timer_wait,sum(number_of_bytes)
as number_of_bytes,event_name,operation from events_waits_current where
EVENT_NAME !='idle' group by EVENT_NAME,OPERATION
4、查看耗时的等待事件
select sys.format_time(timer_wait),sys.format_bytes(number_of_bytes),event_name,operation from sys.test_waits
where sys.format_time(timer_wait) not regexp 'ns|us|ms' order by sys.format_time(timer_wait) desc