My Experience Using Oracle SQL Plan Baselines 11g/12cNelson Calero
This presentation shows how to use the Oracle database functionality SQL Plan Baselines, with examples from real life usage on production (mostly 11gR2) and how to troubleshoot it.
SQL Plan Baselines is a feature introduced on 11g to manage SQL execution plans to prevent performance regressions. The concepts will be presented, along with examples, and some edge cases.
게임 서비스를 위한 AWS상의 고성능 SQL 데이터베이스 구성 (이정훈 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018Amazon Web Services Korea
게임 서비스를 위한 AWS상의 고성능 SQL 데이터베이스 구성
게임 서비스 아키텍처에서 관계형 데이터베이스는 핵심 컴포넌트이며 또한 전체 서비스의 성능 병목 지점이 되곤 합니다. 이 세션에서는 AWS 상에서 게임 서비스를 구현할 때, 기존 물리환경에서의 DB 성능과 동일하거나 더 높은 성능을 얻을 수 있는 구성을 설명 드리며, MS SQL 구성의 성능 데모를 시연하고자 합니다.
SOUG Day Oracle 21c New Security FeaturesStefan Oehrli
With the Innovation Release 21c Oracle has introduced one or the other security feature. These include small improvements that make DB operation more secure and easier. But also completely new concepts like DB Nest, which introduce a new approach for databases, how DB security can be implemented in multitenant.
Oracle 12cR2 Installation On Linux With ASMArun Sharma
Oracle 12c release 2 installation on Oracle Linux 7.6 with ASM. If you already know, Oracle ASM binaries comes with Grid Software!
Here is the full link of article: https://www.support.dbagenesis.com/post/oracle-12c-installation-on-linux-with-asm
My Experience Using Oracle SQL Plan Baselines 11g/12cNelson Calero
This presentation shows how to use the Oracle database functionality SQL Plan Baselines, with examples from real life usage on production (mostly 11gR2) and how to troubleshoot it.
SQL Plan Baselines is a feature introduced on 11g to manage SQL execution plans to prevent performance regressions. The concepts will be presented, along with examples, and some edge cases.
게임 서비스를 위한 AWS상의 고성능 SQL 데이터베이스 구성 (이정훈 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018Amazon Web Services Korea
게임 서비스를 위한 AWS상의 고성능 SQL 데이터베이스 구성
게임 서비스 아키텍처에서 관계형 데이터베이스는 핵심 컴포넌트이며 또한 전체 서비스의 성능 병목 지점이 되곤 합니다. 이 세션에서는 AWS 상에서 게임 서비스를 구현할 때, 기존 물리환경에서의 DB 성능과 동일하거나 더 높은 성능을 얻을 수 있는 구성을 설명 드리며, MS SQL 구성의 성능 데모를 시연하고자 합니다.
SOUG Day Oracle 21c New Security FeaturesStefan Oehrli
With the Innovation Release 21c Oracle has introduced one or the other security feature. These include small improvements that make DB operation more secure and easier. But also completely new concepts like DB Nest, which introduce a new approach for databases, how DB security can be implemented in multitenant.
Oracle 12cR2 Installation On Linux With ASMArun Sharma
Oracle 12c release 2 installation on Oracle Linux 7.6 with ASM. If you already know, Oracle ASM binaries comes with Grid Software!
Here is the full link of article: https://www.support.dbagenesis.com/post/oracle-12c-installation-on-linux-with-asm
Agenda:
Architectural Overview
Presentation to the Client
Presentation to the Server/DB
High Availability and Disaster Recovery
Extended Architecture
Setup / Installation
Tests
Use cases
Perspective 12c
"Dear Students,
Greetings from www.etraining.guru
We provide BEST online training for IBM DB2 LUW/UDB DBA by a database architect. Our DB2 Trainer comes with a working experience of 11+ years, 9+ years in DB2 and a DB2 certified professional.
DB2 LUW DBA Course Content: http://www.etraining.guru/course/dba/online-training-db2-luw-udb-dba
Course Cost: USD 350 (or) INR 21000
Number of Hours: 30-35 hours
Regards,
Karthik
www.etraining.guru"
Automating Your Clone in E-Business Suite R12.2Michael Brown
It is possible to automate the cloning process in Oracle E-Business Suite 12.2. This presentation discusses how to accomplish that and gives some warnings about when it is not possible to run a clone.
For OAUG members, the slides and a recording of the presentation are available on www.oaug.org.
This is the latest version of the slides based on my book "Solaris Performance and Tuning" that has been extended to include Linux and many other more recent topics. It has been presented innumerable times, most recently at the CMG conference, Usenix 08 and LISA 08, and this version will be presented at Usenix 09, San Diego on June 16th, along with the Free Tools slides.
Oracle RAC Virtualized - In VMs, in Containers, On-premises, and in the CloudMarkus Michalewicz
This presentation discusses the support guidelines for using Oracle Real Application Clusters (RAC) in virtualized environments, for which general Oracle Database support guidelines are discussed shortly first.
First presented during DOAG 2021 User Conference, this presentation replaces its predecessor from 2016: https://www.slideshare.net/MarkusMichalewicz/how-to-use-oracle-rac-in-a-cloud-a-support-question
Testing Big Data: Automated Testing of Hadoop with QuerySurgeRTTS
Are You Ready? Stepping Up To The Big Data Challenge In 2016 - Learn why Testing is pivotal to the success of your Big Data Strategy.
According to a new report by analyst firm IDG, 70% of enterprises have either deployed or are planning to deploy big data projects and programs this year due to the increase in the amount of data they need to manage.
The growing variety of new data sources is pushing organizations to look for streamlined ways to manage complexities and get the most out of their data-related investments. The companies that do this correctly are realizing the power of big data for business expansion and growth.
Learn why testing your enterprise's data is pivotal for success with big data and Hadoop. Learn how to increase your testing speed, boost your testing coverage (up to 100%), and improve the level of quality within your data - all with one data testing tool.
With the Oracle Multitenant option of Oracle Database 12c, the services of individual pluggable databases (PDBs) can be opened selectively on specified nodes of an Oracle Real Application Clusters (Oracle RAC) cluster. A true symbiotic relationship: the Oracle Multitenant option makes Oracle RAC better, and Oracle RAC makes the Oracle Multitenant option better! UPDATE for IOUG 2014.
Optimize DR and Cloning with Logical Hostnames in Oracle E-Business Suite (OA...Andrejs Prokopjevs
This presentation covers the idea of logical hostname feature and its possible use case with E-Business Suite, why it is a must-have configuration for DR, how it can improve your test/dev instance cloning and lifecycle processes, especially in a cloud deployment, support overview by 11i/R12.0/R12.1, and why it is a very hot topic right now for R12.2. Additionally, we will describe possible advanced configuration scenarios like container based virtualization. The content is based on real client environment implementation experience.
When Web-based business applications communicate with each other, producer applications ENQUEUE messages and consumer applications DEQUEUE messages. Advanced Queuing provides database-integrated message queuing functionality. Advanced Queuing leverages the functions of the Oracle database so that messages can be stored persistently, propagated between queues on different machines and databases, and transmitted using Oracle Net Services, HTTP(S), and SMTP.
Agenda:
Architectural Overview
Presentation to the Client
Presentation to the Server/DB
High Availability and Disaster Recovery
Extended Architecture
Setup / Installation
Tests
Use cases
Perspective 12c
"Dear Students,
Greetings from www.etraining.guru
We provide BEST online training for IBM DB2 LUW/UDB DBA by a database architect. Our DB2 Trainer comes with a working experience of 11+ years, 9+ years in DB2 and a DB2 certified professional.
DB2 LUW DBA Course Content: http://www.etraining.guru/course/dba/online-training-db2-luw-udb-dba
Course Cost: USD 350 (or) INR 21000
Number of Hours: 30-35 hours
Regards,
Karthik
www.etraining.guru"
Automating Your Clone in E-Business Suite R12.2Michael Brown
It is possible to automate the cloning process in Oracle E-Business Suite 12.2. This presentation discusses how to accomplish that and gives some warnings about when it is not possible to run a clone.
For OAUG members, the slides and a recording of the presentation are available on www.oaug.org.
This is the latest version of the slides based on my book "Solaris Performance and Tuning" that has been extended to include Linux and many other more recent topics. It has been presented innumerable times, most recently at the CMG conference, Usenix 08 and LISA 08, and this version will be presented at Usenix 09, San Diego on June 16th, along with the Free Tools slides.
Oracle RAC Virtualized - In VMs, in Containers, On-premises, and in the CloudMarkus Michalewicz
This presentation discusses the support guidelines for using Oracle Real Application Clusters (RAC) in virtualized environments, for which general Oracle Database support guidelines are discussed shortly first.
First presented during DOAG 2021 User Conference, this presentation replaces its predecessor from 2016: https://www.slideshare.net/MarkusMichalewicz/how-to-use-oracle-rac-in-a-cloud-a-support-question
Testing Big Data: Automated Testing of Hadoop with QuerySurgeRTTS
Are You Ready? Stepping Up To The Big Data Challenge In 2016 - Learn why Testing is pivotal to the success of your Big Data Strategy.
According to a new report by analyst firm IDG, 70% of enterprises have either deployed or are planning to deploy big data projects and programs this year due to the increase in the amount of data they need to manage.
The growing variety of new data sources is pushing organizations to look for streamlined ways to manage complexities and get the most out of their data-related investments. The companies that do this correctly are realizing the power of big data for business expansion and growth.
Learn why testing your enterprise's data is pivotal for success with big data and Hadoop. Learn how to increase your testing speed, boost your testing coverage (up to 100%), and improve the level of quality within your data - all with one data testing tool.
With the Oracle Multitenant option of Oracle Database 12c, the services of individual pluggable databases (PDBs) can be opened selectively on specified nodes of an Oracle Real Application Clusters (Oracle RAC) cluster. A true symbiotic relationship: the Oracle Multitenant option makes Oracle RAC better, and Oracle RAC makes the Oracle Multitenant option better! UPDATE for IOUG 2014.
Optimize DR and Cloning with Logical Hostnames in Oracle E-Business Suite (OA...Andrejs Prokopjevs
This presentation covers the idea of logical hostname feature and its possible use case with E-Business Suite, why it is a must-have configuration for DR, how it can improve your test/dev instance cloning and lifecycle processes, especially in a cloud deployment, support overview by 11i/R12.0/R12.1, and why it is a very hot topic right now for R12.2. Additionally, we will describe possible advanced configuration scenarios like container based virtualization. The content is based on real client environment implementation experience.
When Web-based business applications communicate with each other, producer applications ENQUEUE messages and consumer applications DEQUEUE messages. Advanced Queuing provides database-integrated message queuing functionality. Advanced Queuing leverages the functions of the Oracle database so that messages can be stored persistently, propagated between queues on different machines and databases, and transmitted using Oracle Net Services, HTTP(S), and SMTP.
DBMS_STATS 패키지에는 몇 개의 유용한 프러시저가 있는데 아래와 같다.
gather_database_ stats: 데이터베이스의 모든 Object에 대한 통계 정보 생성.
gather_schema_ stats: 해당 스키마의 모든 Object에 대한 통계 정보 생성.
gather_table_stats : 테이블과 그 테이블과 연관된 인덱스에 대한 통계 정보 생성.
gather_index_stats : 인덱스에 대해 통계 정보를 생성.
탑크리에듀교육센터(www.topcredu.co.kr)제공
스프링프레임워크 & 마이바티스(Spring Framework, MyBatis)
20번째 자료입니다. 참고하시어 많은 도움되셨길 바랍니다.
교육 및 수강문의/기타문의사항은 홈페이지(www.topcredu.co.kr)를 통하여 하실 수 있습니다.^^
-- 먼저 EMP에 테이블에 생성되어 있는 인덱스 및 칼럼을 확인하자.
SQL> SELECT a.index_name, a.column_name, b.visibility
FROM user_ind_columns a, user_indexes b
WHERE a.table_name = 'EMP'
AND a.index_name = b.index_name ;
-- 인덱스가 없다면 생성, 있으면 SKIP
SQL> CREATE INDEX idx_emp_job ON EMP(job);
SQL> CREATE INDEX idx_emp_deptno ON EMP(deptno);
WHERE절에 인덱스 구성 컬럼이 ‘<’>’와 같이 범위 제한 연산자에 의해 이용되거나 BETWEEN or LIKE와 같은 조건 절에 이용될 때 INDEX RANGE SCAN을 하게 된다. 만약 결합(복합) 인덱스라면 범위 제한자에 사용되는 컬럼은 인덱스 구성 컬럼 중 선두 컬럼이여야 한다. 조건을 만족하는 첫 번째 레코드를 인덱스 블록에서 추출 후 조건에 맞는 데이터가 나올 때 까지 계속 스캔하는 나가는 방식으로 INDEX, INDEX_ASC 힌트를 사용할 때 나타나는 연산자이다.
아래 예에서 EMP TABLE에는 sal에 대해 오름차순 순방향 인덱스가 구성되어 있다.
(Index Range Scan이 가능하도록 하는 힌트는 INDEX_RS 이다.)
SQL*Plus에서 사용자는 자동으로 Optimizer가 만드는 실행계획과 통계정보를 얻을 수 있다. 이런 경우 AUTOTRACE를 사용하며 DML문을 성공적으로 수행 시 실행계획과 통계정보가 만들어지며 DML문의 성능 튜닝을 위한 방법으로 자주 이용된다.
SET AUTOTRACE를 사용하기 위해선 실행 계획용 테이블(PLAN_TABLE)이 존재해야 하며 구문을 활성화하기 위해 SET AUTOTRACE ON, 비활성화 하기 위해 SET AUTOTRACE OFF하면 된다. 참고로 SET AUTOTRACE에서 사용할 수 있는 옵션은 다음과 같다.
탑크리에듀교육센터(www.topcredu.co.kr)제공
스프링프레임워크 & 마이바티스(Spring Framework, MyBatis)
21번째 자료입니다. 참고하시어 많은 도움되셨길 바랍니다.
교육 및 수강문의/기타문의사항은 홈페이지(www.topcredu.co.kr)를 통하여 하실 수 있습니다.^^
SPA(SQL Performance Analyze)를 이용한 통계 정보 수집_Wh oracle
1. 112│2013 기술백서 White Paper
SPA(SQL Performance Analyze)를 이용한 통계 정보
수집
㈜엑셈 컨설팅본부/DB컨설팅팀 오 경렬
1. SPA란?
SPA(SQL Performance Analyze)는 RAT(Real Application Testing)서비스의 옵션 중에 하나
이다. 본 문서는 SPA 를 이용해 좀더 안정적으로 통계정보를 생성하는 Process 에 대해 다룬다.
2. 통계 정보와 SQL Tuning
튜닝은 LEADING(A) USE_NL(B) INDEX(A A(COL1))처럼 간단한 힌트로 대부분 해결 가능하
다. 이것이 가능한 이유는 Leading 과 같은 힌트로 쿼리의 키 조건이 무엇인지 지정해주면 나머
지 플랜은 Oracle Optimizer 가 Query Transformation 등 최적화 알고리즘을 적용해 최적의
성능을 낼 수 있도록 플랜을 작성하기 때문이다.
튜너 A 가 사이트에 튜닝 지원을 간다.
사이트에 도착한 A 는 가지고 있던 스크립트로 능숙하게 Tuning 대상을 발췌한다.
수집 기준은 Execution 이 1000 번 이상이면서 Buffer Gets 이 10000 Block 이상인 쿼리
무려 200 개의 쿼리가 추출되었다...
A 군은 순간 당황했지만 빠르게 안정을 되찾고
입고 있던 와이셔츠의 소매 단추를 풀고 두번 접어올리고 나서는 차고 있던 시계를 풀어 책상 위
에 올려 놓는다.
시간은 9 시 30 분을 지나고 있다.
"흠.. 오늘 몇 개나 할 수 있을까...."
A 군은 알듯 말듯한 미소를 지어 보이고는 중지 손가락으로 안경을 한번 치켜 올리고 이내 불꽃
튜닝에 들어간다
2. Part 1 ORACLE │113
그리고.. 엑셀에 하나 둘 완료된 쿼리가 늘어날 때 마다... 희열을 느낀다....
이 글을 보는 당신은 어떻게 할 것인가?
A 군의 판단이 잘못된 것인가?
잘못된 판단이 아니다 최선의 판단이다..... 11g 전 까지는....
11g New Feature 인 Pending Statistics 를 SPA 와 함께 사용한다면
A 군의 200 개의 튜닝 대상 쿼리는 10 개 내외로 줄어 들 수도 있다.
오라클 Optimizer 는 생각보다 똑똑하다.
3. SPA 사용 가능 여부 확인
RAT Option 이 FALSE 면 사용할 수 없다.
SELECT * FROM V$OPTION
WHERE PARAMETER = 'Real Application Testing'
PARAMETER VALUE
-------------------------------------- --------
Real Application Testing TRUE
4. 사용 예
간단한 사례를 다룬다. 본인의 것으로 흡수하고 수정해서 실무에 적용하길 바란다.
시나리오 요약
0. 테스트 스키마 생성 및 쿼리 수행
1. SQL_SET 생성
2. ANALYSIS_TASK #1 생성
3. SCHEMA or TABLE Pending Statistcs 설정
4. 통계 정보 수집
5. Session Use Pending Statistics 설정
3. 114│2013 기술백서 White Paper
6. ANALYSIS_TASK #2 생성
7. ANALYSIS_TASK #1, #2 비교
8. 리포팅
9. 비교 결과 조회 스크립트
0. 테스트 스키마 생성 및 쿼리 수행
DROP TABLE EXEM_T1 PURGE;
CREATE TABLE EXEM_T1
AS
SELECT LEVEL C1, 'A' C2
FROM DUAL
CONNECT BY LEVEL <= 100000;
INSERT INTO EXEM_T1 VALUES(1, 'B');
CREATE INDEX I1_EXEM_T1 ON EXEM_T1(C2) TABLESPACE TSD_QM;
EXEC DBMS_STATS.GATHER_TABLE_STATS(OWNNAME =>'MAXGAUGE'
, TABNAME =>'EXEM_T1'
, NO_INVALIDATE =>FALSE
, METHOD_OPT =>'FOR ALL COLUMNS SIZE 3'
, ESTIMATE_PERCENT =>10);
-- SQL 수행 (A, B 두 가지가 있고 분포가 좋지 않음 -> FTS)
SELECT COUNT(C1)
FROM EXEM_T1
WHERE C2 = :B1;
--COUNT(C1)
--100000
1. SQL_SET 생성
SELECT ID,
4. Part 1 ORACLE │115
NAME,
OWNER,
DESCRIPTION,
CREATED,
LAST_MODIFIED,
STATEMENT_COUNT
FROM DBA_SQLSET
where name = 'OKR_TEST';
--ID NAME OWNER DESCRIPTION CREATED LAST_MODIFIED STATEMENT_COUNT
--24 OKR_TEST MAXGAUGE 2013-06-27 오후 1:37:31 2013-06-27 오후
1:37:43 4
-- SQLSET 과 ANALYSIS_TASK 연결 고리 확인
SELECT DESCRIPTION
FROM DBA_SQLSET_REFERENCES
WHERE SQLSET_NAME = 'OKR_TEST';
--DESCRIPTION
--created by: SQL Performance Analyzer - task: OKR_SPA
SELECT TASK_NAME,
EXECUTION_NAME,
EXECUTION_TYPE,
STATUS,
EXECUTION_END
FROM USER_ADVISOR_EXECUTIONS
WHERE TASK_NAME = 'OKR_SPA';
--TASK_NAME EXECUTION_NAME EXECUTION_TYPE STATUS EXECUTION_END
--OKR_SPA OKR_AFTER TEST EXECUTE COMPLETED 2013-06-27 오후 1:48:07
--OKR_SPA OKR_BEFORE TEST EXECUTE COMPLETED 2013-06-27 오후 1:42:52
--OKR_SPA OKR_COMP COMPARE PERFORMANCE COMPLETED 2013-06-27 오후 1:48:34
-- TASK 가 존재할 경우 SET 삭제 전에 TASK 먼저 삭제해야 그 다음 SET 삭제가 가능하다.
-- ANALYSIS_TASK DROP
EXEC DBMS_SQLPA.DROP_ANALYSIS_TASK('OKR_SPA');
-- TUNING SET DROP
EXEC DBMS_SQLTUNE.DROP_SQLSET('OKR_TEST');
5. 116│2013 기술백서 White Paper
2. ANALYSIS_TASK #1 생성
ANALYSIS_TASK 는 4 가지 방법으로 생성 가능하다.
(1) Sql text format
EXEC :stmt_task := DBMS_SQLPA.CREATE_ANALYSIS_TASK(
sql_text => 'select quantity_sold from sales s, times t where s.time_id = t.time_id
and s.time_id = TO_DATE(''24-NOV-00'')');
(2) Sql id format (cursor cache)
EXEC :stmt_task := DBMS_SQLPA.CREATE_ANALYSIS_TASK(sql_id => 'ay1m3ssvtrh24');
(3) Workload repository format
exec :stmt_task := DBMS_SQLPA.CREATE_ANALYSIS_TASK(
begin_snap => 1,
end_snap => 2,
sql_id => 'ay1m3ssvtrh24');
(4) Sql tuning set format (first we need to load an STS, then analyze it)
EXEC :sts_task := DBMS_SQLPA.CREATE_ANALYSIS_TASK( --- sqlset_name => 'my_workload',
--- order_by => 'BUFFER_GETS', --- description => 'process workload ordered by
buffer gets');
--아래는 Sql tuning set format 사용한 예제이다.
--SQLSET 생성
EXEC DBMS_SQLTUNE.CREATE_SQLSET('OKR_TEST');
--내용을 채워넣는다
--COMMAND TYPE
--2 --> insert
--3 --> select (for update)
--6 --> update
6. Part 1 ORACLE │117
--7 --> delete
--189 --> merge
DECLARE
cur DBMS_SQLTUNE.SQLSET_CURSOR;
BEGIN
OPEN cur FOR
SELECT VALUE(P)
FROM table(
DBMS_SQLTUNE.SELECT_CURSOR_CACHE(
'parsing_schema_name in (''MAXGAUGE'')
and upper(sql_text) like ''%EXEM_T1%''
AND command_type IN (2,3,6,7,189)',
NULL, NULL, NULL, NULL, 1, NULL,
'ALL')) P;
DBMS_SQLTUNE.LOAD_SQLSET(sqlset_name => 'OKR_TEST'
,populate_cursor => cur);
END;
----update and delete SQL statements from an STS based on a search condition
--BEGIN
-- DBMS_SQLTUNE.DELETE_SQLSET(
-- sqlset_name => 'my_sql_tuning_set',
-- basic_filter => 'executions < 50');
--END;
--/
--
-- Task 생성 확인
select count(1) from DBA_SQLSET_STATEMENTS where sqlset_name = 'OKR_TEST'
--count(1)
--4
-- 생성
DECLARE
TNAME VARCHAR2(30);
BEGIN
TNAME := DBMS_SQLPA.CREATE_ANALYSIS_TASK( SQLSET_NAME => 'OKR_TEST'
, BASIC_FILTER => NULL
, ORDER_BY => 'EXECUTIONS'
, TOP_SQL => 100
7. 118│2013 기술백서 White Paper
, TASK_NAME => 'OKR_SPA'
, DESCRIPTION => NULL
, SQLSET_OWNER => NULL
);
END;
-- EXECUTE_ANALYSIS_TASK
-- 가장 빠른 방법은 execution_type => 'CONVERT SQLSET'
-- ANALYSIS_TASK 생성
begin
DBMS_SQLPA.EXECUTE_ANALYSIS_TASK(
task_name => 'OKR_SPA',
execution_type => 'EXECUTE',
execution_name => 'OKR_BEFORE');
end;
-- 생성 결과 조회
select execution_name
,status
,execution_end
,execution_end
from USER_ADVISOR_EXECUTIONS
where task_name = 'OKR_SPA';
--EXECUTION_NAME STATUS EXECUTION_END
--OKR_BEFORE COMPLETED 2013-07-02 오후 3:04:03
3. SCHEMA or TABLE Pending Statistcs 설정
-- 조회 결과가 TRUE 이면 Pending 이 걸려있지 않은 상태다
SELECT DBMS_STATS.GET_PREFS('PUBLISH', 'maxgauge', 'EXeM_T1') PUBLISH FROM DUAL;
--PUBLISH
--TRUE
-- FALSE 로 변경 -> 운영간에 통계정보 생성에 의한 플랜 변경을 막기위한 조치
Exec dbms_stats.set_schema_prefs('maxgauge', pname => 'PUBLISH', pvalue => 'FALSE');
8. Part 1 ORACLE │119
4. 통계정보 수집
-- 거의 대부분의 데이터를 지우고 Histogram 도 생성하기 때문에 인덱스를 이용함
delete exem_t1
where c2 = 'A'
-- 통계정보 재생성
exec dbms_stats.gather_table_stats(ownname =>'MAXGAUGE'
, tabname =>'EXEM_T1'
, no_invalidate =>FALSE
, method_opt =>'for all columns size 3'
, estimate_percent=>10);
-- Pending 통계 조회
SELECT * FROM DBA_TAB_PENDING_STATS
WHERE TABLE_NAME = 'EXEM_T1'
-- 하지만 통계를 Pending 했으므로 여전히 FTS 플랜
select count(c1)
from exem_t1
where c2 = :b1;
--Pending 상태에서 수집한 최신 통계정보를 이용해서 SPA 수행
5. Session Use Pending Statistics 설정
alter session set optimizer_use_pending_statistics = TRUE;
-- 하지만 통계를 Pending 했으므로 여전히 FTS 플랜
select count(c1)
from exem_t1
where c2 = :b1;
6. ANALYSIS_TASK #2 생성
-- OKR_AFTER 이름으로 TASK 를 만든다.
begin
DBMS_SQLPA.EXECUTE_ANALYSIS_TASK(
9. 120│2013 기술백서 White Paper
task_name => 'OKR_SPA',
execution_type => 'EXECUTE',
execution_name => 'OKR_AFTER');
새 섹션 2 페이지 5
execution_name => 'OKR_AFTER');
end;
7. ANALYSIS_TASK #1, #2 비교
begin
DBMS_SQLPA.EXECUTE_ANALYSIS_TASK(
task_name => 'OKR_SPA',
execution_type => 'COMPARE PERFORMANCE',
execution_name => 'OKR_COMP',
execution_params => dbms_advisor.arglist(
'execution_name1',
'OKR_BEFORE',
'execution_name2',
'OKR_AFTER'
)
);
end;
8. 리포팅
set long 100000 longchunksize 100000 linesize 200 head off feedback off echo off
spool report.html
SELECT dbms_sqlpa.report_analysis_task('OKR_SPA', 'HTML', 'ALL','ALL') FROM dual;
spool off
--Click here to see the file report.html in html formart
;
10. Part 1 ORACLE │121
9. 비교 결과 조회 스크립트
with TMP as
(
select /*+ materialize */
11. 122│2013 기술백서 White Paper
b.sql_id
,b.plan_hash_value b_ph
,a.plan_hash_value a_ph
,case when (b.buffer_gets-a.buffer_gets) >= 0
then '개선'
when (b.buffer_gets-a.buffer_gets) < 0
then '저하'
end "성능"
,b.optimizer_cost b_cost
,a.optimizer_cost a_cost
,b.executions b_exec
,a.executions a_exec
,b.rows_processed b_rows
,a.rows_processed a_rows
,b.elapsed_time B_ET
,a.elapsed_time A_ET
,b.buffer_gets B_BG
,a.buffer_gets A_BG
,b.disk_reads b_dr
,a.disk_reads a_dr
,round(100-
(decode(a.buffer_gets,0,1,a.buffer_gets)/decode(b.buffer_gets,0,1,b.buffer_gets))*100,
1) bg_rate
,round(100-
(decode(a.elapsed_time,0,1,a.elapsed_time)/decode(b.elapsed_time,0,1,b.elapsed_time))*
100,1) et_rate
from dba_advisor_sqlstats b
,dba_advisor_sqlstats a
where 1=1
and b.execution_name = :before
and a.execution_name = :after
and a.sql_id = b.sql_id
and a.plan_hash_value <> b.plan_hash_value
)
select /*+ leading(a) use_nl(r) */
hash_value hv
,a.*
,parsing_schema_name pars_nm
,sql_profile Pf
,module
,executions R_EXEC
12. Part 1 ORACLE │123
,round(BUFFER_GETS/decode(executions,0,1,executions),0) R_BG
,round(DISK_READS/decode(executions,0,1,executions),1) R_DR
,round(ROWS_PROCESSED/decode(executions,0,1,executions),0) R_ROWS
,round(ELAPSED_TIME/decode(executions,0,1,executions)/1000000,1) R_ET
,round(CPU_TIME/decode(executions,0,1,executions)/1000000,1) R_CT
,last_active_time last_t
,first_load_time first_t
,sql_fulltext text
from tmp a
,v$sqlarea r
where a.sql_id = r.sql_id
5. 마치며
본 문서의 내용은 프로그램으로 치면 "Hello World" 이다. 꼭 내용을 숙지하고 스크립트나 엑셀
메크로 등으로 자동화하여 업무에 적용하길 바란다. 이론은 절대 경험을 이기지 못한다.