Oracle : SQL Server 용 프로파일 러와 같은 쿼리를 추적하는 도구가 있습니까?
SQL 서버로 작업하지만 Oracle DB가있는 애플리케이션으로 마이그레이션해야합니다. 내 응용 프로그램 쿼리를 추적하기 위해 Sql Server에서 멋진 프로파일 러 도구를 사용합니다. 오라클에 상응하는 것이 있습니까?
Oracle Enterprise Manager를 사용하여 실행중인 쿼리, 실행 계획, 잠금, 일부 통계 및 더 긴 작업에 대한 진행률 표시 줄과 함께 활성 세션을 모니터링 할 수 있습니다.
참조 : http://download.oracle.com/docs/cd/B10501_01/em.920/a96674/db_admin.htm#1013955
인스턴스-> 세션으로 이동하여 각 세션의 SQL 탭을 확인하십시오.
다른 방법이 있습니다. Enterprise Manager는 http://www.oracle.com/pls/db92/db92.catalog_views?remark=homepage에 설명 된 것과 같은 특별보기에서 이미 사용할 수있는 항목을 예쁜 색상으로 표시합니다 .
물론 Explain PLAN FOR, TRACE 도구 및 기타 다양한 도구화 방법을 사용할 수도 있습니다. 엔터프라이즈 관리자에는 가장 비싼 SQL 쿼리에 대한 몇 가지 보고서가 있습니다. 캐시에 보관 된 최근 쿼리를 검색 할 수도 있습니다.
쉬운 해결책을 찾았습니다
1 단계. PLSQL 또는 sqldeveloper 또는 기타 쿼리 인터페이스를 사용하여 관리자로 DB에 연결
2 단계. 다음 스크립트를 실행하십시오. S.SQL_TEXT 열에서 실행 된 쿼리를 볼 수 있습니다.
SELECT
S.LAST_ACTIVE_TIME,
S.MODULE,
S.SQL_FULLTEXT,
S.SQL_PROFILE,
S.EXECUTIONS,
S.LAST_LOAD_TIME,
S.PARSING_USER_ID,
S.SERVICE
FROM
SYS.V_$SQL S,
SYS.ALL_USERS U
WHERE
S.PARSING_USER_ID=U.USER_ID
AND UPPER(U.USERNAME) IN ('oracle user name here')
ORDER BY TO_DATE(S.LAST_LOAD_TIME, 'YYYY-MM-DD/HH24:MI:SS') desc;
유일한 문제는 입력 매개 변수 값 (함수 호출 용)을 표시하는 방법을 찾을 수 없다는 것입니다.하지만 적어도 특정 도구를 사용하지 않고도 Oracle에서 실행되는 내용과 순서를 볼 수 있습니다.
alter system set timed_statistics=true
--또는
alter session set timed_statistics=true --if want to trace your own session
-충분히 커야합니다.
select value from v$parameter p
where name='max_dump_file_size'
-관심있는 세션의 sid 및 일련 번호를 찾으십시오.
select sid, serial# from v$session
where ...your_search_params...
--10046 이벤트로 추적을 시작할 수 있으며, 네 번째 매개 변수는 추적 레벨을 설정합니다 (12가 가장 큼).
begin
sys.dbms_system.set_ev(sid, serial#, 10046, 12, '');
end;
-제로 레벨 설정으로 추적 끄기 :
begin
sys.dbms_system.set_ev(sid, serial#, 10046, 0, '');
end;
/ * 가능한 수준 : 0-꺼짐 1-최소 수준. set sql_trace = true 4-바인드 변수 값이 추적 파일에 추가됨 8-대기가 추가됨 12-바인드 변수 값과 대기 이벤트가 모두 추가됨 * /
-더 큰 수준으로 자신의 세션을 추적하려는 경우에도 동일합니다.
alter session set events '10046 trace name context forever, level 12';
--끄다:
alter session set events '10046 trace name context off';
-원시 추적 정보가있는 파일은 다음 위치에 있습니다.
select value from v$parameter p
where name='user_dump_dest'
-파일 이름 (* .trc)에는 spid가 포함됩니다.
select p.spid from v$session s, v$process p
where s.paddr=p.addr
and ...your_search_params...
-또한 직접 이름을 설정할 수 있습니다.
alter session set tracefile_identifier='UniqueString';
-마지막으로 TKPROF
추적 파일을 더 읽기 쉽게 만드는 데 사용 합니다.
C:\ORACLE\admin\databaseSID\udump>
C:\ORACLE\admin\databaseSID\udump>tkprof my_trace_file.trc output=my_file.prf
TKPROF: Release 9.2.0.1.0 - Production on Wed Sep 22 18:05:00 2004
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
C:\ORACLE\admin\databaseSID\udump>
-추적 파일 사용 상태보기 :
set serveroutput on size 30000;
declare
ALevel binary_integer;
begin
SYS.DBMS_SYSTEM.Read_Ev(10046, ALevel);
if ALevel = 0 then
DBMS_OUTPUT.Put_Line('sql_trace is off');
else
DBMS_OUTPUT.Put_Line('sql_trace is on');
end if;
end;
/
번역 된 http://www.sql.ru/faq/faq_topic.aspx?fid=389 원본은 더 꽉 차 있지만 어쨌든 다른 사람이 IMHO를 게시 한 것보다 낫습니다.
프로파일 러에 대한 사용자 친화적 인 GUI 인터페이스가있는 PL / SQL Developer를 사용해보십시오. 재판을 시도해 보는 것은 꽤 좋습니다. Oracle 데이터베이스에서 작업 할 때이 도구를 사용한다고 맹세합니다.
http://www.allroundautomations.com/plsqldev.html?gclid=CM6pz8e04p0CFQjyDAodNXqPDw
SQL Server 프로파일 러와 유사하게 실행되는 쿼리를 캡처하는 Oracle 용 도구입니다. 이 데이터베이스 서버를 사용하는 응용 프로그램의 유지 관리에 필수적인 도구입니다.
공식 사이트 iacosoft.com에서 다운로드 할 수 있습니다.
Seeing as I've just voted a recent question as a duplicate and pointed in this direction . . .
A couple more - in SQL*Plus - SET AUTOTRACE ON - will give explain plan and statistics for each statement executed.
TOAD also allows for client side profiling.
The disadvantage of both of these is that they only tell you the execution plan for the statement, but not how the optimiser arrived at that plan - for that you will need lower level server side tracing.
Another important one to understand is Statspack snapshots - they are a good way for looking at the performance of the database as a whole. Explain plan, etc, are good at finding individual SQL statements that are bottlenecks. Statspack is good at identifying the fact your problem is that a simple statement with a good execution plan is being called 1 million times in a minute.
The Catch is Capture all SQL run between two points in time. Like the way SQL Server also does.
There are situations where it is useful to capture the SQL that a particular user is running in the database. Usually you would simply enable session tracing for that user, but there are two potential problems with that approach.
- The first is that many web based applications maintain a pool of persistent database connections which are shared amongst multiple users.
- The second is that some applications connect, run some SQL and disconnect very quickly, making it tricky to enable session tracing at all (you could of course use a logon trigger to enable session tracing in this case).
A quick and dirty solution to the problem is to capture all SQL statements that are run between two points in time.
The following procedure will create two tables, each containing a snapshot of the database at a particular point. The tables will then be queried to produce a list of all SQL run during that period.
If possible, you should do this on a quiet development system - otherwise you risk getting way too much data back.
Take the first snapshot Run the following sql to create the first snapshot:
create table sql_exec_before as select executions,hash_value from v$sqlarea /
Get the user to perform their task within the application.
Take the second snapshot.
create table sql_exec_after as select executions, hash_value from v$sqlarea /
Check the results Now that you have captured the SQL it is time to query the results.
This first query will list all query hashes that have been executed:
select aft.hash_value
from sql_exec_after aft
left outer join sql_exec_before bef
on aft.hash_value = bef.hash_value
where aft.executions > bef.executions
or bef.executions is null;
/
This one will display the hash and the SQL itself: set pages 999 lines 100 break on hash_value
select hash_value, sql_text
from v$sqltext
where hash_value in (
select aft.hash_value
from sql_exec_after aft
left outer join sql_exec_before bef
on aft.hash_value = bef.hash_value
where aft.executions > bef.executions
or bef.executions is null;
)
order by
hash_value, piece
/
5. Tidy up Don't forget to remove the snapshot tables once you've finished:
drop table sql_exec_before
/
drop table sql_exec_after
/
Oracle, along with other databases, analyzes a given query to create an execution plan. This plan is the most efficient way of retrieving the data.
Oracle provides the 'explain plan
' statement which analyzes the query but doesn't run it, instead populating a special table that you can query (the plan table).
The syntax (simple version, there are other options such as to mark the rows in the plan table with a special ID, or use a different plan table) is:
explain plan for <sql query>
The analysis of that data is left for another question, or your further research.
There is a commercial tool FlexTracer which can be used to trace Oracle SQL queries
This is an Oracle doc explaining how to trace SQL queries, including a couple of tools (SQL Trace and tkprof)
Apparently there is no small simple cheap utility that would help performing this task. There is however 101 way to do it in a complicated and inconvenient manner.
Following article describes several. There are probably dozens more... http://www.petefinnigan.com/ramblings/how_to_set_trace.htm
'program tip' 카테고리의 다른 글
Python에서 sys.path에 파일 경로를 영구적으로 추가 (0) | 2020.10.15 |
---|---|
Gradle에서 ''AppPlugin '유형의 플러그인을 만들 수 없습니다.'라는 오류가 발생합니다. (0) | 2020.10.15 |
DLL에는 무엇이 있으며 어떻게 작동합니까? (0) | 2020.10.15 |
정의되지 않은 동작을 포함하는 소스 코드가 컴파일러를 충돌시키는 것이 합법적입니까? (0) | 2020.10.15 |
RESTful 웹 서비스에서 로그인을 어떻게 구현합니까? (0) | 2020.10.15 |