Home > Database > Oracle > How to check the execution record time of stored procedure in Oracle query

How to check the execution record time of stored procedure in Oracle query

下次还敢
Release: 2024-04-18 22:09:19
Original
1042 people have browsed it

In Oracle, you can query the stored procedure execution record time through the following method: use the DBMS_PROFILER package to obtain execution statistics. Use the V$PROFILER view to get statistics on executing SQL statements and PL/SQL units. Use Oracle Monitor to view related events in the session event history. Use the AUDIT plug-in to audit stored procedure execution and obtain information in the audit file.

How to check the execution record time of stored procedure in Oracle query

How to query the stored procedure execution record time in Oracle

In Oracle, you can query the storage through the following method Process execution record time:

1. Use the DBMS_PROFILER package

The DBMS_PROFILER package provides the function of viewing stored procedure execution statistics, including execution time. To use this package:

1

2

3

4

5

6

7

8

9

10

<code class="sql">BEGIN

  -- 开始剖析

  DBMS_PROFILER.START_PROFILING;

 

  -- 执行您的存储过程

  -- ...

 

  -- 结束剖析并获取结果

  DBMS_PROFILER.END_PROFILING;

END;</code>

Copy after login

The results will be stored in the DBMS_PROFILER.RESULTS table, which you can query to get the execution time of the stored procedure:

1

2

3

<code class="sql">SELECT * FROM DBMS_PROFILER.RESULTS

WHERE OBJECT_TYPE = 'PROCEDURE'

AND OBJECT_NAME = '您的存储过程名称';</code>

Copy after login

2. Using V$ PROFILER view

The V$PROFILER view provides statistical information about SQL statements and PL/SQL units being executed in the current or most recently run session. To use this view:

1

2

3

<code class="sql">SELECT * FROM V$PROFILER

WHERE OBJECT_TYPE = 'PROCEDURE'

AND OBJECT_NAME = '您的存储过程名称';</code>

Copy after login

3. Using Oracle Monitor

Oracle Monitor is a graphical user interface (GUI) that allows you to view Various statistics, including stored procedure execution time. To use Oracle Monitor:

  • Start Oracle Monitor and connect to your database.
  • Expand the "Session" panel and select the session that executes the stored procedure.
  • In the Event History tab, find events related to your stored procedure execution.

4. Using the AUDIT plug-in

The AUDIT plug-in allows you to audit activity in your database, including the execution of stored procedures. To use the AUDIT plug-in:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

<code class="sql">-- 启用 AUDIT 插件

ALTER SYSTEM SET AUDIT_TRAIL='DB' SCOPE=SPFILE;

 

-- 启用存储过程审核

AUDIT EXECUTE ON PROCEDURE BY PUBLIC;

 

-- 执行您的存储过程

-- ...

 

-- 禁用存储过程审核

AUDIT EXECUTE ON PROCEDURE BY PUBLIC REVOKE;

 

-- 禁用 AUDIT 插件

ALTER SYSTEM SET AUDIT_TRAIL='NONE' SCOPE=SPFILE;</code>

Copy after login

You can find information about the execution time of a stored procedure in the audit file.

The above is the detailed content of How to check the execution record time of stored procedure in Oracle query. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template