Issue - (#3): README file update.
parent
8db480c070
commit
3857313837
23
README.md
23
README.md
|
@ -130,6 +130,29 @@ There are four views, and complete statistics can be accessed using these views.
|
||||||
query | text | | |
|
query | text | | |
|
||||||
slow_query | text | | |
|
slow_query | text | | |
|
||||||
|
|
||||||
|
Examples
|
||||||
|
1 - Here in this query we are getting the exact value of f1 = '05:06:07-07' where in case of slow query.
|
||||||
|
|
||||||
|
# select userid, queryid, query, slow_query, max_time, total_calls from pg_stat_agg_user;
|
||||||
|
-[ RECORD 1 ]----------------------------------------------------------------------------------------
|
||||||
|
userid | 10
|
||||||
|
queryid | -203926152419851453
|
||||||
|
query | SELECT f1 FROM TIMETZ_TBL WHERE f1 < $1
|
||||||
|
slow_query | SELECT f1 FROM TIMETZ_TBL WHERE f1 < '05:06:07-07';
|
||||||
|
max_time | 1.237875
|
||||||
|
total_calls | 8
|
||||||
|
|
||||||
|
2 - Collect all the statistics based on user.
|
||||||
|
|
||||||
|
# select usename, query, max_time, total_calls from pg_stat_agg_user au, pg_user u where au.userid = u.usesysid;
|
||||||
|
usename | query | max_time | total_calls
|
||||||
|
---------+---------------------------------------------------------+----------+-------------
|
||||||
|
vagrant | select userid, query, total_calls from pg_stat_agg_user | 0.268842 | 7
|
||||||
|
foo | select userid, query, total_calls from pg_stat_agg_user | 0.208551 | 1
|
||||||
|
vagrant | select * from pg_stat_monitor_reset() | 0.0941 | 1
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
|
|
||||||
#### Limitation
|
#### Limitation
|
||||||
There are some limitations and Todo's.
|
There are some limitations and Todo's.
|
||||||
|
|
||||||
|
|
|
@ -84,9 +84,9 @@ SELECT
|
||||||
ss.query,
|
ss.query,
|
||||||
ss.slow_query
|
ss.slow_query
|
||||||
FROM pg_stat_agg() agg
|
FROM pg_stat_agg() agg
|
||||||
INNER JOIN (SELECT DISTINCT queryid, userid, query, host, min_time, max_time, mean_time, hist_calls, hist_min_time, hist_max_time,hist_mean_time,slow_query,cpu_user_time,cpu_sys_time
|
INNER JOIN (SELECT DISTINCT queryid, dbid, userid, query, host, min_time, max_time, mean_time, hist_calls, hist_min_time, hist_max_time,hist_mean_time,slow_query,cpu_user_time,cpu_sys_time
|
||||||
FROM pg_stat_monitor) ss
|
FROM pg_stat_monitor) ss
|
||||||
ON agg.queryid = ss.queryid AND agg.type = 0;
|
ON agg.queryid = ss.queryid AND agg.type = 0 AND id = dbid;
|
||||||
|
|
||||||
CREATE VIEW pg_stat_agg_user AS
|
CREATE VIEW pg_stat_agg_user AS
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -110,7 +110,7 @@ SELECT
|
||||||
ss.slow_query
|
ss.slow_query
|
||||||
FROM pg_stat_agg() agg
|
FROM pg_stat_agg() agg
|
||||||
INNER JOIN (SELECT DISTINCT queryid, userid, query, host, min_time, max_time, mean_time, hist_calls, hist_min_time, hist_max_time,hist_mean_time,slow_query,cpu_user_time,cpu_sys_time FROM pg_stat_monitor) ss
|
INNER JOIN (SELECT DISTINCT queryid, userid, query, host, min_time, max_time, mean_time, hist_calls, hist_min_time, hist_max_time,hist_mean_time,slow_query,cpu_user_time,cpu_sys_time FROM pg_stat_monitor) ss
|
||||||
ON agg.queryid = ss.queryid AND agg.type = 1;
|
ON agg.queryid = ss.queryid AND agg.type = 1 AND id = userid;
|
||||||
|
|
||||||
CREATE VIEW pg_stat_agg_host AS
|
CREATE VIEW pg_stat_agg_host AS
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -134,7 +134,7 @@ SELECT
|
||||||
ss.slow_query
|
ss.slow_query
|
||||||
FROM pg_stat_agg() agg
|
FROM pg_stat_agg() agg
|
||||||
INNER JOIN (SELECT DISTINCT queryid, userid, query, host, min_time, max_time, mean_time, hist_calls, hist_min_time, hist_max_time,hist_mean_time,slow_query,cpu_user_time,cpu_sys_time FROM pg_stat_monitor) ss
|
INNER JOIN (SELECT DISTINCT queryid, userid, query, host, min_time, max_time, mean_time, hist_calls, hist_min_time, hist_max_time,hist_mean_time,slow_query,cpu_user_time,cpu_sys_time FROM pg_stat_monitor) ss
|
||||||
ON agg.queryid = ss.queryid AND agg.type = 2;
|
ON agg.queryid = ss.queryid AND agg.type = 2 AND id = host;
|
||||||
|
|
||||||
GRANT SELECT ON pg_stat_agg_database TO PUBLIC;
|
GRANT SELECT ON pg_stat_agg_database TO PUBLIC;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue