PostgreSQLスキルアップノート(自己啓発のための個人サイト)

統計情報コレクタの標準統計情報ビュー・ファンクション関連情報編


【一覧に戻る】

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
■■■■ PostgreSQL スキルアップノート
■■■■
■◆■■ 統計情報コレクタの標準統計情報ビュー・ファンクション関連情報編
■■■■
■■■■
■■■■ 2012/11/17
■■■■ 使用環境:PostgreSQL9.1.4 (CentOS6.2)
                                                                   (C) 2012 ohdb
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
★自己都合により実機確認は9.1、マニュアルへのリンクは9.2としています。ご了承下さい。


【マニュアル】
・統計情報コレクタ→●[マニュアル]データベース活動状況の監視−統計情報コレクタ
・実行時統計情報→●[マニュアル]サーバの設定−実行時統計情報


【参考記事】
なし

・統計情報コレクタによって反映された情報





■1■ pg_stat_user_functions  ★特に重要
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

このビューはアプリケーション(関数)の実行回数や処理時間を把握できる。
track_functionsパラメータの設定が必要【重要】

・total_timeはこの関数から呼ばれた関数の実行時間も含む ms
・self_timeはこの関数のみの実行時間ms
・pg_stat_user_functionsにはallやsysはない



【□】 

select
 schemaname,
 funcname  ,
 calls     ,
 total_time,
 self_time,
 total_time/calls as total_time_per_exec,
 self_time/calls as self_time_per_exec
from pg_stat_user_functions order by 1,2;




 schemaname |    funcname     | calls | total_time | self_time | total_time_per_exec | self_time_per_exec
------------+-----------------+-------+------------+-----------+---------------------+--------------------
 pg_catalog | col_description |    24 |          1 |         1 |                   0 |                  0
 public     | fnc_test1       |     5 |       1866 |      1866 |                 373 |                373



test1=# \d+ pg_stat_user_functions
        View "pg_catalog.pg_stat_user_functions"
   Column   |  Type  | Modifiers | Storage | Description
------------+--------+-----------+---------+-------------
 funcid     | oid    |           | plain   |
 schemaname | name   |           | plain   |
 funcname   | name   |           | plain   |
 calls      | bigint |           | plain   |
 total_time | bigint |           | plain   |
 self_time  | bigint |           | plain   |

View definition:
 SELECT 
     p.oid AS funcid,
     n.nspname AS schemaname,
     p.proname AS funcname,
     pg_stat_get_function_calls(p.oid) AS calls,
     pg_stat_get_function_time(p.oid) / 1000 AS total_time,
     pg_stat_get_function_self_time(p.oid) / 1000 AS self_time
   FROM pg_proc p
   LEFT JOIN pg_namespace n ON n.oid = p.pronamespace
  WHERE p.prolang <> 12::oid 
  AND pg_stat_get_function_calls(p.oid) IS NOT NULL;






以上 
inserted by FC2 system