ORACLE优化查询资源消耗的语句

1、SQL ordered by Gets
select *
from (select substr(sql_text, 1, 40) sql,
buffer_gets,
executions,
buffer_gets / executions “Gets/Exec”,
hash_value,
address
from v$sqlarea
where buffer_gets > 0
and executions > 0
order by buffer_gets desc)
where rownum <= 10;

2、SQL ordered by Reads
select *
from (select substr(sql_text, 1, 40) sql,
disk_reads,
executions,
disk_reads / executions “Reads/Exec”,
hash_value,
address
from v$sqlarea
where disk_reads > 0
and executions > 0
order by disk_reads desc)
where rownum <= 10;

3、SQL ordered by Executions
select *
from (select substr(sql_text, 1, 40) sql,
executions,
rows_processed,
rows_processed / executions “Rows/Exec”,
hash_value,
address
from v$sqlarea
where executions > 0
order by executions desc)
where rownum <= 10;

4、SQL ordered by Parse Calls
select *
from (select substr(sql_text, 1, 40) sql,
parse_calls,
executions,
hash_value,
address
from v$sqlarea
where parse_calls > 0
order by parse_calls desc)
where rownum <= 10;

5、Running Time top 10 sql
select *
from (select t.sql_fulltext,
(t.last_active_time –
to_date(t.first_load_time, ‘yyyy – mm – dd hh24 :mi :ss‘)) * 24 * 60,
disk_reads,
buffer_gets,
rows_processed,
t.last_active_time,
t.last_load_time,
t.first_load_time
from v$sqlarea t
order by t.first_load_time desc)
where rownum < 10;

Oracle EBS汇总模板建立问题处理

当建立总账汇总模板时,报错:

Copyright (c) 1979, 1999, Oracle Corporation. All rights reserved.

GLSTPM module: 增加/删除汇总账户
+---------------------------------------------------------------------------+

当前的系统时间为 24-08-2020 09:41:45

+---------------------------------------------------------------------------+


>> main() 24-08-2020 09:41:45

>> glsini() 24-08-2020 09:41:45
STPM0021: 默认优化系数为 0。

<< glsini() 24-08-2020 09:41:45

>> glstexs() 24-08-2020 09:41:45

<< glstexs() 24-08-2020 09:41:45

>> glsfst() 24-08-2020 09:41:45

>> open_cursor() 24-08-2020 09:41:45

<< open_cursor() 24-08-2020 09:41:45

>> load_segnum_vsid() 24-08-2020 09:41:45

<< load_segnum_vsid() 24-08-2020 09:41:45

>> do_fetch_templates() 24-08-2020 09:41:45
SHRD0108: 从 GL_SUMMARY_TEMPLATES 中取回 1 记录

<< do_fetch_templates() 24-08-2020 09:41:45

>> close_cursor() 24-08-2020 09:41:45

<< close_cursor() 24-08-2020 09:41:45

<< glsfst() 24-08-2020 09:41:45

>> glsltmp() 24-08-2020 09:41:45

>> gludlk() 24-08-2020 09:41:45

<< gludlk() 24-08-2020 09:41:45

<< glsltmp() 24-08-2020 09:41:45

>> glstexs() 24-08-2020 09:41:45

<< glstexs() 24-08-2020 09:41:45

>> glsuab() 24-08-2020 09:41:45

<< glsuab() 24-08-2020 09:41:45

>> glstadd() 24-08-2020 09:41:45

>> glucmt() 24-08-2020 09:41:45

<< glucmt() 24-08-2020 09:41:45
STPM0003: 已验证模板 "D-D-LEV1-D-D-D-D-D-D-D-D",并已定义全部累计组。

>> glsdsh() 24-08-2020 09:41:45
SHRD0119: 从 GL_SUMMARY_HIERARCHIES 中删除 0 记录。
SHRD0119: 从 GL_SUMMARY_HIERARCHY_INT 中删除 0 记录。

>> glucmt() 24-08-2020 09:41:45

<< glucmt() 24-08-2020 09:41:45

<< glsdsh() 24-08-2020 09:41:45

>> glsdah() 24-08-2020 09:41:45
SHRD0119: 从 GL_CODE_COMBINATIONS 中删除 0 记录。

>> glucmt() 24-08-2020 09:41:45

<< glucmt() 24-08-2020 09:41:45

<< glsdah() 24-08-2020 09:41:45

>> glsash() 24-08-2020 09:41:45
SHRD0117: 把 761 记录插入 GL_SUMMARY_HIERARCHIES

>> glucmt() 24-08-2020 09:41:45

<< glucmt() 24-08-2020 09:41:45

<< glsash() 24-08-2020 09:41:45

>> glsmah() 24-08-2020 09:41:45

>> gls_fill_seg_info() 24-08-2020 09:41:45

<< gls_fill_seg_info() 24-08-2020 09:41:45

>> gls_get_max_ccid() 24-08-2020 09:41:45

>> glucmt() 24-08-2020 09:41:45

<< glucmt() 24-08-2020 09:41:45

<< gls_get_max_ccid() 24-08-2020 09:41:45

>> glstmt() 24-08-2020 09:41:45

<< glstmt() 24-08-2020 09:41:45

>> gls_csa_rollup() 24-08-2020 09:41:45

>> glsgsmi() 24-08-2020 09:41:45
SHRD0114: 正在执行 Pro*C 语句 Insert into gl_sum_int ...

SHRD0043: ERROR: ORA-00001: 违反唯一约束条件 (GL.GL_SUMMARY_INT_2_U1)
         

<x glsgsmi() 24-08-2020 09:41:45

<x gls_csa_rollup() 24-08-2020 09:41:45
SHRD0075: 在 gls_csa_rollup() 的错误.

<x glsmah() 24-08-2020 09:41:45
SHRD0075: 在 glsmah() 的错误.

<x glstadd() 24-08-2020 09:41:45
SHRD0075: 在 glstadd_addtmp() 的错误.

问题处理:

通过脚本检查总账科目设置问题:

applprod:

@/u01/PROD/app/fs1/EBSapps/appl/gl/12.0.0/sql/glxacovl.sql

 

处理完直接的子父级后:

重新删除之前错误的模板,运行:
增加/删除汇总账户

运行完成后,重新新增模板即可。

具体sql如下:
SELECT vs.flex_value_set_name value_set_name,
fvh1.parent_flex_value ancestor,
gl_flexfields_pkg.get_parent_from_children(val.flex_value_set_id,
fvh1.parent_flex_value,
fvh1.child_flex_value_low,
fvh1.child_flex_value_high,
1) parent_flex_value,
fvh1.child_flex_value_low child_flex_value_low,
fvh1.child_flex_value_high child_flex_value_high,
gl_flexfields_pkg.get_parent_from_children(val.flex_value_set_id,
fvh1.parent_flex_value,
fvh2.child_flex_value_low,
fvh2.child_flex_value_high,
2) parent_flex_value2,
fvh2.child_flex_value_low child_flex_value_low2,
fvh2.child_flex_value_high child_flex_value_high2
FROM fnd_flex_values val,
fnd_flex_value_sets vs,
fnd_flex_value_hierarchies fvh1,
fnd_flex_value_hierarchies fvh2
WHERE val.structured_hierarchy_level IS NOT NULL
AND vs.flex_value_set_id = val.flex_value_set_id
AND fvh1.flex_value_set_id = val.flex_value_set_id
AND fvh1.parent_flex_value = val.flex_value
AND fvh2.flex_value_set_id = val.flex_value_set_id
AND fvh2.parent_flex_value = val.flex_value
AND fvh2.child_flex_value_low BETWEEN fvh1.child_flex_value_low AND fvh1.child_flex_value_high
AND (fvh2.child_flex_value_low <> fvh1.child_flex_value_low OR
fvh2.rowid < fvh1.rowid)
AND fvh2.rowid <> fvh1.rowid
ORDER BY 1, 2, 3, 4, 5, 6, 7, 8

Oracle sysaux表空间占用问题处理

现象:

oracle sysaux表空间占用96%。通过awrinfo.sql报告核实组件:SM/AWR占用27,317.2 MB;SM/OPTSTAT 390.1 MB,大部分是AWR报告占用。

解决方法:

删除快照,回收表及index。

1、修改统计信息的保持时间,默认为31天,这里修改为7天,过期的统计信息会自动被删除

select dbms_stats.get_stats_history_retention from dual;

exec dbms_stats.alter_stats_history_retention(7);

select dbms_stats.get_stats_history_retention from dual;

2、删除AWR快照,最后再次查看SYSAUX表空间使用率(非业务时间,分段操作,以免引起临时空间增大)

select min(snap_id),max(snap_id) from dba_hist_snapshot;//查询最最小和最大快照ID

begin

dbms_workload_repository.drop_snapshot_range( low_snap_id => 32155, high_snap_id => 32300, dbid => 2950336419);

end;

3、回收降低水位

alter table WRH$_EVENT_HISTOGRAM move partition WRH$_EVENT__2950336419_2060;
alter index WRH$_EVENT_HISTOGRAM_PK rebuild partition WRH$_EVENT__2950336419_2060;

技术笔记(小潘的技术记录博客)