开心时刻
一个传说中的库特别慢
看了看等待,发现failed logon delay事件居前
其实不重要,非要查个明白的话,那就
-
select username, to_char(timestamp,'mm-dd hh24:mi:ss') datetime, action_name, priv_used, obj_name, ses_actions
-
from sys.dba_audit_trail
-
where timestamp>sysdate-1and action_name = 'logon'
-
order by username;
-
-
或
-
select audit_type,
-
os_username,
-
userhost,
-
terminal,
-
dbusername,
-
dbproxy_username,
-
client_program_name,
-
to_char(event_timestamp,
-
'mm-dd hh24:mi:ss') datetime, action_name, return_code, unified_audit_policies
-
from unified_audit_trail
-
where event_timestamp>sysdate-1
-
and action_name = 'logon'
-
and return_code is not null
-
order by dbusername;
或者
-
col ntimestamp# for a30 heading "timestamp"
-
col userid for a6 heading "username"
-
col userhost for a15 heading "machine"
-
col spare1 for a10 heading "os user"
-
col comment$text for a80 heading "details"
-
-
select ntimestamp#, userid, userhost, spare1, comment$text,returncode
-
from sys.aud$ where returncode=1017 or returncode=28000;
如果关闭审计,那么就不会看到真凶,解决办法可以直接设置初始化参数:
-
event="28401 trace name context forever, level 1" # disable logon delay.
前戏结束(详见 doc id 2724913.1)
收集统计信息技巧
如果因为某种原因(报错、提高效率。。。)收集全库(用户)统计信息时排除掉其他用户的表,可以这样:
-
execute dbms_stats.lock_table_stats ('owner name', 'table name');
-
exec dbms_stats.gather_database_stats;
-
execute dbms_stats.unlock_table_stats ('owner name', 'table name');
正题来了,收集方法如下:
-
-
exec dbms_stats.gather_database_stats(estimate_percent => 20, degree => 32, cascade => true, gather_sys=> false);
对参数不了解可以
-
select dbms_stats.get_prefs('cascade') pref_cascade from dual;
-
select dbms_stats.get_prefs('estimate_percent') pref_cascade from dual;
-
-
随着产品成熟,后期会倾向于越来越简单
exec dbms_stats.gather_database_stats 即可
深入一下:默认采样百分比多少,我这可是4t大库,要等多久?
终于可以引用这个:it depends on
先说明百分比,这个比较清晰:
-
https://blogs.oracle.com/optimizer/post/how-does-auto-sample-size-work-in-oracle-database-12c
so,具体要等多久,大概4小时吧。
-
dbms_stats.gather_database_stats (
-
estimate_percent number default to_estimate_percent_type (get_param('estimate_percent')),
-
block_sample boolean default false,
-
method_opt varchar2 default get_param('method_opt'),
-
degree number default to_degree_type(get_param('degree')),
-
granularity varchar2 default get_param('granularity'),
-
cascade boolean default to_cascade_type(get_param('cascade')),
-
stattab varchar2 default null,
-
statid varchar2 default null,
-
options varchar2 default 'gather',
-
objlist out objecttab,
-
statown varchar2 default null,
-
gather_sys boolean default true,
-
no_invalidate boolean default to_no_invalidate_type (get_param('no_invalidate')),
-
obj_filter_list objecttab default null);
-
-
dbms_stats.gather_database_stats (
-
estimate_percent number default to_estimate_percent_type (get_param('estimate_percent')),
-
block_sample boolean default false,
-
method_opt varchar2 default get_param('method_opt'),
-
degree number default to_degree_type(get_param('degree')),
-
granularity varchar2 default get_param('granularity'),
-
cascade boolean default to_cascade_type(get_param('cascade')),
-
stattab varchar2 default null,
-
statid varchar2 default null,
-
options varchar2 default 'gather',
-
statown varchar2 default null,
-
gather_sys boolean default true,
-
no_invalidate boolean default to_no_invalidate_type ( get_param('no_invalidate')),
-
obj_filter_list objecttab default null);
友情提示:
good。
阅读(9533) | 评论(0) | 转发(0) |