索引问题引起的执行计划偏移(EBS Cost Management performance issue )

本文主要是介绍索引问题引起的执行计划偏移(EBS Cost Management performance issue ),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

之前遇到的一个EBS性能问题,更新至CSDN

Create Accounting - Cost Management_performance issue

SYMPTOMS

元旦过后,create accounting cost management执行时间过长,还时常报错,影响正常作业;

1.对比2018/12和2019/01的报表执行时间,确实能看到

Accounting Program和create accounting cost management比上个月的执行时间要长太多 (data from MTRDB)

cid:image005.png@01D4ACAF.6FE77100

通过具体对比每天的执行log,发现是从01/07日开始执行时间变长

由原来的平均15分钟左右,到超过1000分钟

ANALYZE

根据出现问题的时间点,首先想到是拉出AWR report,对比发生问题前后的AWR,发现在发生问题后的AWR有两个异常的SQL。

Sql1:
 

BEGIN xla_accounting_pkg.unit_processor_batch(:errbuf, :rc, :A0, :A1, :A2, :A3, :A4, :A5, :A6, :A7, :A8, :A9, :A10, :A11, :A12, :A13, :A14); END;Sql2:SELECT /*+ leading(xet) cardinality(xet,1) */XET.ENTITY_ID,XET.LEGAL_ENTITY_ID,XET.ENTITY_CODE,XET.TRANSACTION_NUMBER,XET.EVENT_ID,XET.EVENT_CLASS_CODE,XET.EVENT_TYPE_CODE,XET.EVENT_NUMBER,XET.EVENT_DATE,XET.TRANSACTION_DATE,XET.REFERENCE_NUM_1,XET.REFERENCE_NUM_2,XET.REFERENCE_NUM_3,XET.REFERENCE_NUM_4,XET.REFERENCE_CHAR_1,XET.REFERENCE_CHAR_2,XET.REFERENCE_CHAR_3,XET.REFERENCE_CHAR_4,XET.REFERENCE_DATE_1,XET.REFERENCE_DATE_2,XET.REFERENCE_DATE_3,XET.REFERENCE_DATE_4,XET.EVENT_CREATED_BY,XET.BUDGETARY_CONTROL_FLAG,L2.LINE_NUMBER,L2.CODE_COMBINATION_ID SOURCE_4,L2.ACCOUNTING_LINE_TYPE_CODE SOURCE_5,L2.DISTRIBUTION_IDENTIFIER SOURCE_6,L2.ENTERED_AMOUNT SOURCE_8,L2.CURRENCY_CODE SOURCE_9,L2.CURRENCY_CONVERSION_DATE SOURCE_10,L2.CURRENCY_CONVERSION_RATE SOURCE_11,L2.CURRENCY_CONVERSION_TYPE SOURCE_12,L2.ACCOUNTED_AMOUNT SOURCE_13FROM XLA_EVENTS_GT XET, CST_XLA_INV_LINES_V L2WHERE XET.EVENT_ID BETWEEN :B5 AND :B4AND XET.EVENT_DATE BETWEEN :B3 and :B2

其中sql1為sql2的top level sql,也就是sql2是由sql1 call起的

查看SQL2的执行计划,除了MTL_TRANSACTION_ACCOUNTS_N6的基数过大外,其他没有太大异常。当时也有检查该执行计划,查到MTL_TRANSACTION_ACCOUNTS_N6索引所在的基表是一个1.7亿数据的大表,但没有将该问题视为问题点,去对比测试区执行计划。

  1. 将此问题在MOS检索,查到相关Bug较多

Create Accounting - Cost Management Program Performance Problem (Doc ID 1380982.1)

This is explained in the following bug:
Bug 12898461 - CREATE ACCOUNTING - COST MANAGEMENT PROGRAM PERFORMANCE PROBLEM

故就此问题开SR,寻求oracle support协助。

select * from table(dbms_xplan.display_cursor('d4wkbj1knh6y8',null,'ADVANCED ALLSTATS LAST'));select * from table(dbms_xplan.display_cursor('872zgwkyjdw09', null, 'peeked_binds'));

发现生成sql执行计划的检索范围非常大
 

Peeked Binds (identified by position):--------------------------------------1 - (NUMBER): 822482732 - (NUMBER): 822607313 - (DATE): 06/01/2001 00:00:004 - (DATE): 01/02/2019 00:00:005 - (VARCHAR2(30), CSID=867): 'WIP_MTL'Predicate Information (identified by operation id):

考虑到01/05日有做过gather schema,怀疑是不是gather schema后第一个request把时间范围设置错误,但是查询request记录,发现用户数据只有当前时间点,也就是2001这个时间点是系统带出来的。

想到目前crp3可以正常运行,便对比crp3中该SQL的执行计划。并且联系华硕的Douglas,确认华硕那边该SQL的执行计划如下:

两者均是走的索引MTL_TRANSACTION_ACCOUNTS_N1,而非N6

cid:image001.png@01D4ADAF.2853CE50

考虑到时间紧急,于是在正式区直接将MTL_TRANSACTION_ACCOUNTS_N6设置为invisible(使优化器不可见),重新运行create accounting cost management,结果可以正常运行,执行计划也与测试区一致。

SOLUTION

  1. cancel all request about create accounting cost management

  2. check no sql_id ('872zgwkyjdw09','d4wkbj1knh6y8')execute on db

  3. mark index MTL_TRANSACTION_ACCOUNTS_N6 invisible

alter index inv.MTL_TRANSACTION_ACCOUNTS_N6 invisible;

    4.submit new request “create accounting cost management”

    5. check explain plan is right

select * from table(dbms_xplan.display_cursor('d4wkbj1knh6y8',null,'ADVANCED ALLSTATS LAST'));select * from table(dbms_xplan.display_cursor('872zgwkyjdw09', null, 'peeked_binds'));

   6.use sql profile bind explain plan with sql_id

SQL> @/home/ora920/jobs/coe_xfr_sql_profile.sql ---execute sql profrile sqlParameter 1:SQL_ID (required)Enter value for 1: d4wkbj1knh6y8 ---enter the sql idPLAN_HASH_VALUE AVG_ET_SECS--------------- -----------574263622 .0322234976105 4032.48Parameter 2:PLAN_HASH_VALUE (required)Enter value for 2: 574263622 ---select the short time hashValues passed to coe_xfr_sql_profile:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~SQL_ID : "d4wkbj1knh6y8"PLAN_HASH_VALUE: "574263622"SQL>BEGIN2 IF :sql_text IS NULL THEN3 RAISE_APPLICATION_ERROR(-20100, 'SQL_TEXT for SQL_ID &&sql_id. was not found in memory (gv$sqltext_with_newlines) or AWR (dba_hist_sqltext).');4 END IF;5 END;6 /SQL>SET TERM OFF;SQL>BEGIN2 IF :other_xml IS NULL THEN3 RAISE_APPLICATION_ERROR(-20101, 'PLAN for SQL_ID &&sql_id. and PHV &&plan_hash_value. was not found in memory (gv$sql_plan) or AWR (dba_hist_sql_plan).');4 END IF;5 END;6 /SQL>SET TERM OFF;Execute coe_xfr_sql_profile_d4wkbj1knh6y8_574263622.sqlon TARGET system in order to create a custom SQL Profilewith plan 574263622 linked to adjusted sql_text.COE_XFR_SQL_PROFILE completed.SQL>SQL>exitora920@erpdb(/home/ora920/jobs)$ ls -lrttotal 5872-rw-rw---- 1 ora920 dba 18248 Jan 16 17:22 coe_xfr_sql_profile.sql-rw-r--r-- 1 ora920 dba 6200 Jan 16 17:23 coe_xfr_sql_profile_d4wkbj1knh6y8_574263622.sql --- generate sql script-rw-r--r-- 1 ora920 dba 19981 Jan 16 17:23 coe_xfr_sql_profile.logora920@erpdb(/home/ora920/jobs)$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.2.0 Production on Wed Jan 16 17:25:53 2019Copyright (c) 1982, 2010, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> @/home/ora920/jobs/coe_xfr_sql_profile_d4wkbj1knh6y8_574263622.sql---execute this sql script bind sql plan hash with sql_idSQL> REMSQL> REM $Header: 215187.1 coe_xfr_sql_profile_d4wkbj1knh6y8_574263622.sql 11.4.4.4 2019/01/16 carlos.sierra $SQL> REMSQL> REM Copyright (c) 2000-2012, Oracle Corporation. All rights reserved.SQL> REMSQL> REM AUTHORSQL> REM carlos.sierra@oracle.comSQL> REMSQL> REM SCRIPTSQL> REM coe_xfr_sql_profile_d4wkbj1knh6y8_574263622.sqlSQL> REMSQL> REM DESCRIPTIONSQL> REM This script is generated by coe_xfr_sql_profile.sqlSQL> REM It contains the SQL*Plus commands to create a customSQL> REM SQL Profile for SQL_ID d4wkbj1knh6y8 based on plan hashSQL> REM value 574263622.SQL> REM The custom SQL Profile to be created by this scriptSQL> REM will affect plans for SQL commands with signatureSQL> REM matching the one for SQL Text below.SQL> REM Review SQL Text and adjust accordingly.SQL> REMSQL> REM PARAMETERSSQL> REM None.SQL> REMSQL> REM EXAMPLESQL> REM SQL> START coe_xfr_sql_profile_d4wkbj1knh6y8_574263622.sql;SQL> REMSQL> REM NOTESSQL> REM 1. Should be run as SYSTEM or SYSDBA.SQL> REM 2. User must have CREATE ANY SQL PROFILE privilege.SQL> REM 3. SOURCE and TARGET systems can be the same or similar.SQL> REM 4. To drop this custom SQL Profile after it has been created:SQL> REM EXEC DBMS_SQLTUNE.DROP_SQL_PROFILE('coe_d4wkbj1knh6y8_574263622');SQL> REM 5. Be aware that using DBMS_SQLTUNE requires a licenseSQL> REM for the Oracle Tuning Pack.SQL> REM 6. If you modified a SQL putting Hints in order to produce a desiredSQL> REM Plan, you can remove the artifical Hints from SQL Text pieces below.SQL> REM By doing so you can create a custom SQL Profile for the originalSQL> REM SQL but with the Plan captured from the modified SQL (with Hints).SQL> REMSQL> WHENEVER SQLERROR EXIT SQL.SQLCODE;SQL> REMSQL> VAR signature NUMBER;SQL> VAR signaturef NUMBER;SQL> REMSQL> DECLARE2 sql_txt CLOB;3 h SYS.SQLPROF_ATTR;4 PROCEDURE wa (p_line IN VARCHAR2) IS5 BEGIN6 DBMS_LOB.WRITEAPPEND(sql_txt, LENGTH(p_line), p_line);7 END wa;8 BEGIN9 DBMS_LOB.CREATETEMPORARY(sql_txt, TRUE);10 DBMS_LOB.OPEN(sql_txt, DBMS_LOB.LOB_READWRITE);11 -- SQL Text pieces below do not have to be of same length.12 -- So if you edit SQL Text (i.e. removing temporary Hints),13 -- there is no need to edit or re-align unmodified pieces.14 wa(q'[SELECT /*+ leading(xet) cardinality(xet,1) */ XET.ENTITY_ID ,XET]');15 wa(q'[.LEGAL_ENTITY_ID ,XET.ENTITY_CODE ,XET.TRANSACTION_NUMBER ,XET.E]');16 wa(q'[VENT_ID ,XET.EVENT_CLASS_CODE ,XET.EVENT_TYPE_CODE ,XET.EVENT_NU]');17 wa(q'[MBER ,XET.EVENT_DATE ,XET.TRANSACTION_DATE ,XET.REFERENCE_NUM_1 ]');18 wa(q'[,XET.REFERENCE_NUM_2 ,XET.REFERENCE_NUM_3 ,XET.REFERENCE_NUM_4 ,]');19 wa(q'[XET.REFERENCE_CHAR_1 ,XET.REFERENCE_CHAR_2 ,XET.REFERENCE_CHAR_3]');20 wa(q'[ ,XET.REFERENCE_CHAR_4 ,XET.REFERENCE_DATE_1 ,XET.REFERENCE_DATE]');21 wa(q'[_2 ,XET.REFERENCE_DATE_3 ,XET.REFERENCE_DATE_4 ,XET.EVENT_CREATE]');22 wa(q'[D_BY ,XET.BUDGETARY_CONTROL_FLAG , L2.LINE_NUMBER , L2.CODE_COMB]');23 wa(q'[INATION_ID SOURCE_4 , L2.ACCOUNTING_LINE_TYPE_CODE SOURCE_5 , L2]');24 wa(q'[.DISTRIBUTION_IDENTIFIER SOURCE_6 , L2.ENTERED_AMOUNT SOURCE_8 ,]');25 wa(q'[ L2.CURRENCY_CODE SOURCE_9 , L2.CURRENCY_CONVERSION_DATE SOURCE_]');26 wa(q'[10 , L2.CURRENCY_CONVERSION_RATE SOURCE_11 , L2.CURRENCY_CONVERS]');27 wa(q'[ION_TYPE SOURCE_12 , L2.ACCOUNTED_AMOUNT SOURCE_13 FROM XLA_EVEN]');28 wa(q'[TS_GT XET , CST_XLA_INV_LINES_V L2 WHERE XET.EVENT_ID BETWEEN :B]');29 wa(q'[5 AND :B4 AND XET.EVENT_DATE BETWEEN :B3 AND :B2 AND XET.EVENT_C]');30 wa(q'[LASS_CODE = :B1 AND XET.EVENT_STATUS_CODE <> 'N' AND L2.EVENT_ID]');31 wa(q'[ = XET.EVENT_ID ]');32 DBMS_LOB.CLOSE(sql_txt);33 h := SYS.SQLPROF_ATTR(34 q'[BEGIN_OUTLINE_DATA]',35 q'[IGNORE_OPTIM_EMBEDDED_HINTS]',36 q'[OPTIMIZER_FEATURES_ENABLE('11.2.0.2')]',37 q'[DB_VERSION('11.2.0.2')]',38 q'[OPT_PARAM('_b_tree_bitmap_plans' 'false')]',39 q'[OPT_PARAM('_fast_full_scan_enabled' 'false')]',40 q'[ALL_ROWS]',41 q'[OUTLINE_LEAF(@"SEL$D836F37B")]',42 q'[ELIMINATE_JOIN(@"SEL$335DD26A" "TRFMMT"@"SEL$3")]',43 q'[ELIMINATE_JOIN(@"SEL$335DD26A" "MP2"@"SEL$3")]',44 q'[ELIMINATE_JOIN(@"SEL$335DD26A" "WSH"@"SEL$3")]',45 q'[ELIMINATE_JOIN(@"SEL$335DD26A" "XGT"@"SEL$2")]',46 q'[OUTLINE_LEAF(@"SEL$1")]',47 q'[OUTLINE(@"SEL$335DD26A")]',48 q'[MERGE(@"SEL$3")]',49 q'[OUTLINE(@"SEL$2")]',50 q'[OUTLINE(@"SEL$3")]',51 q'[INDEX_RS_ASC(@"SEL$1" "XET"@"SEL$1" ("XLA_EVENTS_GT"."EVENT_ID"))]',52 q'[NO_ACCESS(@"SEL$1" "L2"@"SEL$1")]',53 q'[LEADING(@"SEL$1" "XET"@"SEL$1" "L2"@"SEL$1")]',54 q'[USE_HASH(@"SEL$1" "L2"@"SEL$1")]',55 q'[INDEX_RS_ASC(@"SEL$D836F37B" "XEG"@"SEL$3" ("XLA_EVENTS_GT"."EVENT_ID"))]',56 q'[INDEX_RS_ASC(@"SEL$D836F37B" "GL"@"SEL$2" ("GL_LEDGERS"."LEDGER_ID"))]',57 q'[INDEX_RS_ASC(@"SEL$D836F37B" "MMT"@"SEL$3" ("MTL_MATERIAL_TRANSACTIONS"."TRANSACTION_ID"))]',58 q'[INDEX_RS_ASC(@"SEL$D836F37B" "MTA"@"SEL$2" ("MTL_TRANSACTION_ACCOUNTS"."TRANSACTION_ID"))]',59 q'[INDEX_RS_ASC(@"SEL$D836F37B" "MMT"@"SEL$2" ("MTL_MATERIAL_TRANSACTIONS"."TRANSACTION_ID"))]',60 q'[INDEX(@"SEL$D836F37B" "MP1"@"SEL$3" ("MTL_PARAMETERS"."ORGANIZATION_ID"))]',61 q'[INDEX(@"SEL$D836F37B" "MP"@"SEL$2" ("MTL_PARAMETERS"."ORGANIZATION_ID"))]',62 q'[LEADING(@"SEL$D836F37B" "XEG"@"SEL$3" "GL"@"SEL$2" "MMT"@"SEL$3" "MTA"@"SEL$2" "MMT"@"SEL$2" "MP1"@"SEL$3" "MP"@"SEL$2")]',63 q'[USE_NL(@"SEL$D836F37B" "GL"@"SEL$2")]',64 q'[USE_NL(@"SEL$D836F37B" "MMT"@"SEL$3")]',65 q'[USE_NL(@"SEL$D836F37B" "MTA"@"SEL$2")]',66 q'[USE_NL(@"SEL$D836F37B" "MMT"@"SEL$2")]',67 q'[USE_NL(@"SEL$D836F37B" "MP1"@"SEL$3")]',68 q'[USE_NL(@"SEL$D836F37B" "MP"@"SEL$2")]',69 q'[END_OUTLINE_DATA]');70 :signature := DBMS_SQLTUNE.SQLTEXT_TO_SIGNATURE(sql_txt);71 :signaturef := DBMS_SQLTUNE.SQLTEXT_TO_SIGNATURE(sql_txt, TRUE);72 DBMS_SQLTUNE.IMPORT_SQL_PROFILE (73 sql_text => sql_txt,74 profile => h,75 name => 'coe_d4wkbj1knh6y8_574263622',76 description => 'coe d4wkbj1knh6y8 574263622 '||:signature||' '||:signaturef||'',77 category => 'DEFAULT',78 validate => TRUE,79 replace => TRUE,80 force_match => FALSE /* TRUE:FORCE (match even when different literals in SQL). FALSE:EXACT (similar to CURSOR_SHARING) */ );81 DBMS_LOB.FREETEMPORARY(sql_txt);82 END;83 /PL/SQL procedure successfully completed.SQL> WHENEVER SQLERROR CONTINUESQL> SET ECHO OFF;SIGNATURE---------------------6475979124597627135SIGNATUREF---------------------6475979124597627135... manual custom SQL Profile has been createdCOE_XFR_SQL_PROFILE_d4wkbj1knh6y8_574263622 completedSQL>SQL>SQL> exit

这篇关于索引问题引起的执行计划偏移(EBS Cost Management performance issue )的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/997335

相关文章

springboot循环依赖问题案例代码及解决办法

《springboot循环依赖问题案例代码及解决办法》在SpringBoot中,如果两个或多个Bean之间存在循环依赖(即BeanA依赖BeanB,而BeanB又依赖BeanA),会导致Spring的... 目录1. 什么是循环依赖?2. 循环依赖的场景案例3. 解决循环依赖的常见方法方法 1:使用 @La

SpringBoot启动报错的11个高频问题排查与解决终极指南

《SpringBoot启动报错的11个高频问题排查与解决终极指南》这篇文章主要为大家详细介绍了SpringBoot启动报错的11个高频问题的排查与解决,文中的示例代码讲解详细,感兴趣的小伙伴可以了解一... 目录1. 依赖冲突:NoSuchMethodError 的终极解法2. Bean注入失败:No qu

Spring定时任务只执行一次的原因分析与解决方案

《Spring定时任务只执行一次的原因分析与解决方案》在使用Spring的@Scheduled定时任务时,你是否遇到过任务只执行一次,后续不再触发的情况?这种情况可能由多种原因导致,如未启用调度、线程... 目录1. 问题背景2. Spring定时任务的基本用法3. 为什么定时任务只执行一次?3.1 未启用

MySQL新增字段后Java实体未更新的潜在问题与解决方案

《MySQL新增字段后Java实体未更新的潜在问题与解决方案》在Java+MySQL的开发中,我们通常使用ORM框架来映射数据库表与Java对象,但有时候,数据库表结构变更(如新增字段)后,开发人员可... 目录引言1. 问题背景:数据库与 Java 实体不同步1.1 常见场景1.2 示例代码2. 不同操作

如何解决mysql出现Incorrect string value for column ‘表项‘ at row 1错误问题

《如何解决mysql出现Incorrectstringvalueforcolumn‘表项‘atrow1错误问题》:本文主要介绍如何解决mysql出现Incorrectstringv... 目录mysql出现Incorrect string value for column ‘表项‘ at row 1错误报错

如何解决Spring MVC中响应乱码问题

《如何解决SpringMVC中响应乱码问题》:本文主要介绍如何解决SpringMVC中响应乱码问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录Spring MVC最新响应中乱码解决方式以前的解决办法这是比较通用的一种方法总结Spring MVC最新响应中乱码解

pip无法安装osgeo失败的问题解决

《pip无法安装osgeo失败的问题解决》本文主要介绍了pip无法安装osgeo失败的问题解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一... 进入官方提供的扩展包下载网站寻找版本适配的whl文件注意:要选择cp(python版本)和你py

解决Java中基于GeoTools的Shapefile读取乱码的问题

《解决Java中基于GeoTools的Shapefile读取乱码的问题》本文主要讨论了在使用Java编程语言进行地理信息数据解析时遇到的Shapefile属性信息乱码问题,以及根据不同的编码设置进行属... 目录前言1、Shapefile属性字段编码的情况:一、Shp文件常见的字符集编码1、System编码

Spring MVC使用视图解析的问题解读

《SpringMVC使用视图解析的问题解读》:本文主要介绍SpringMVC使用视图解析的问题解读,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录Spring MVC使用视图解析1. 会使用视图解析的情况2. 不会使用视图解析的情况总结Spring MVC使用视图

Redis解决缓存击穿问题的两种方法

《Redis解决缓存击穿问题的两种方法》缓存击穿问题也叫热点Key问题,就是⼀个被高并发访问并且缓存重建业务较复杂的key突然失效了,无数的请求访问会在瞬间给数据库带来巨大的冲击,本文给大家介绍了Re... 目录引言解决办法互斥锁(强一致,性能差)逻辑过期(高可用,性能优)设计逻辑过期时间引言缓存击穿:给