DBMS_PROFILER包收集并存储在性能剖析会话中执行的关于PL/pgSQL和SPL语句的性能信息。

您可以使用下列表中列出的函数和存储过程来控制剖析工具。

表 1. DBMS PROFILER Functions/Procedures
Function/Procedure Function or Procedure Return Type Description
FLUSH DATA Both Status Code or Exception Flushes performance data collected in the current session without terminating the session (profiling continues).
GET VERSION(major OUT, minor OUT) Procedure n/a Returns the version number of this package.
INTERNAL VERSION CHECK Function Status Code Confirms that the current version of the profiler will work with the current database.
PAUSE PROFILER Both Status Code or Exception Pause data collection.
PAUSE PROFILER Both Status Code or Exception Resume data collection.
START PROFILER(run comment, run commentl [, run number OUT ]) Both Status Code or Exception Start data collection.
STOP PROFILER Both Status Code or Exception Stop data collection and flush performance data to the PLSQL PROFILER RAWDATA table.

DBMS_PROFILER包中的函数返回的是一个表明成功或失效的状态码。只有在DBMS_PROFILER存储过程遇到失效时,DBMS_PROFILER存储过程才会产生异常。下列表中列出了由函数返回的状态码和消息,以及存储过程产生的异常。

表 2. DBMS_PROFILER Status Codes and Exceptions
Status Code Message Exception Description
-1 error version version_mismatch The profiler version and the database are incompatible.
0 success n/a The operation completed successfully.
1 error_param profiler_error The operation received an incorrect parameter.
2 error_io profiler_error The data flush operation has failed.

FLUSH_DATA

在不终结分析器会话的情况下,FLUSH_DATA函数/存储过程会刷新从当前会话中收集的数据。数据将被刷新到POLARDB性能特性指南描述的表中。FLUSH_DATA函数和存储过程的语法如下:

status INTEGER FLUSH_DATA

FLUSH_DATA

参数

参数名称 描述
status 状态码是由运算返回的。

GET_VERSION

GET_VERSION 存储过程返回的是DBMS_PROFILER版本的存储过程。语法如下:

GET_VERSION(major OUT INTEGER, minor OUT INTEGER)

参数

参数名称 描述
major DBMS_PROFILER 主要版本的数量。
minor DBMS_PROFILER 次要版本的数量。

INTERNAL_VERSION_CHECK

The INTERNAL_VERSION_CHECK 函数用于确认DBMS_PROFILER的当前版本是否能与当前数据库工作。函数语法如下:

status INTEGER INTERNAL_VERSION_CHECK

参数

参数名称 描述
status 状态码是由运算返回的。

PAUSE_PROFILER

PAUSE_PROFILER函数/存储过程用于暂停分析会话。语法如下:

status INTEGER PAUSE_PROFILER

PAUSE_PROFILER

参数

参数名称 描述
status 状态码是由运算返回的。

RESUME_PROFILER

RESUME_PROFILER 函数/存储过程用于继续分析会话。RESUME_PROFILER 函数/存储过程语法如下:

status INTEGER RESUME_PROFILER

RESUME_PROFILER

参数

参数名称 描述
status 状态码是由运算返回的。

START_PROFILER

START_PROFILER函数/存储过程用于开始数据收集会话。语法如下:

status INTEGER START_PROFILER(run_comment TEXT := SYSDATE,
  run_comment1 TEXT := '' [, run_number OUT INTEGER ])

START_PROFILER(run_comment TEXT := SYSDATE,
  run_comment1 TEXT := '' [, run_number OUT INTEGER ])

参数

参数名称 描述
run comment 给分析器会话的用户定义的注释。缺省值为SYSDATE。
run commentl 给分析器会话的额外用户定义的注释。缺省值为TT。
run number 分析器会话的数量。
status 状态码是由运算返回的。

STOP_PROFILER

STOP_PROFILER函数/存储过程用于停止分析会话及刷新性能信息到DBMS_PROFILER表和视图中。语法如下:

status INTEGER STOP_PROFILER

STOP_PROFILER

参数

参数名称 描述
status 状态码是由运算返回的。