更新时间:2026-07-28 GMT+08:00
分享

操作指导

前提条件

无。

语法

不涉及。

注意事项

无。

示例

gaussdb=# CREATE TABLE test(a int,b int);
gaussdb=# INSERT INTO test VALUES(generate_series(1,30),2);
gaussdb=# CREATE OR REPLACE PROCEDURE test_proc1()
AS
num int;
BEGIN
SELECT COUNT(*) INTO num FROM test;
END;
/
-- 入参的标识符代表该次profiling的名称,和执行的存储过程名没有关联
gaussdb=# SELECT DBE_PROFILER.PL_START_PROFILING('test_profiler_name');
 pl_start_profiling
--------------------

(1 row)
gaussdb=# CALL test_proc1();
 test_proc1
------------

(1 row)
-- 查看相关系统表的信息
gaussdb=# SELECT * FROM DBE_PROFILER.PL_PROFILING_FUNCTIONS;
        run_id         | funcoid | schema |   funcname   | total_occur | init_time | end_time | total_time
-----------------------+---------+--------+--------------+-------------+-----------+----------+------------
 50_test_profiler_name |   17613 | public | test_proc1() |           1 |         8 |        3 |        921
(1 row)

gaussdb=# SELECT * FROM DBE_PROFILER.PL_PROFILING_DETAILS ORDER BY run_id, funcoid, line#;
        run_id         | funcoid | line# |               source                | cmd_type | total_occur | total_time | max_time | min_time
-----------------------+---------+-------+-------------------------------------+----------+-------------+------------+----------+----------
 50_test_profiler_name |   17613 |     1 |  DECLARE                            |          |           0 |          0 |        0 |        0
 50_test_profiler_name |   17613 |     2 | num int;                            |          |           0 |          0 |        0 |        0
 50_test_profiler_name |   17613 |     3 | begin                               |          |           0 |          0 |        0 |        0
 50_test_profiler_name |   17613 |     4 | select count(*) into num from test; | EXECSQL  |           1 |        904 |      904 |      904
 50_test_profiler_name |   17613 |     5 | end                                 |          |           0 |          0 |        0 |        0
(5 rows)
gaussdb=# SELECT funcoid, step_name, loops_count FROM DBE_PROFILER.PL_PROFILING_TRACKINFO;
 funcoid |  step_name   | loops_count
---------+--------------+-------------
   17613 | init         |           1
   17613 | package      |           1
   17613 | spictx       |           1
   17613 | compile      |           1
   17613 | exec_context |           1
   17613 | execute      |           1
   17613 | exec_cursor  |           1
   17613 | cleanup      |           1
   17613 | finsh        |           0
(9 rows)
gaussdb=# SELECT * FROM DBE_PROFILER.PL_PROFILING_CALLGRAPH;
        run_id         |               stack               | self_time
-----------------------+-----------------------------------+-----------
 50_test_profiler_name | {"public.test_proc1() oid=17613"} |       921
(1 row)
gaussdb=# DROP TABLE test;

相关文档