I am looking for a way to efficiently gather statistics that would tell me how many times each function gets called in a given period of time.

By efficient, I mean the stat collector should use as few disk I/O operations as possible.

It would be nice if I can also track some more stats like the return time however this is not necessary.

有帮助吗?

解决方案

It's already built-in.

Check out the system view pg_stat_user_functions
http://www.postgresql.org/docs/current/static/monitoring-stats.html#PG-STAT-USER-FUNCTIONS-VIEW

Note that you need to enable that in your postgresql.conf:
http://www.postgresql.org/docs/current/static/monitoring-stats.html#MONITORING-STATS-SETUP

To reset the collected statistics, use pg_stat_reset():
http://www.postgresql.org/docs/current/static/monitoring-stats.html#MONITORING-STATS-FUNCTIONS

其他提示

In addition to the features horse mentioned, there's also:

I consider both pgbadger and pg_stat_statements essential components of any production PostgreSQL install.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top