Skip to content

Commit

Permalink
Issue - (#3): README file update.
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrarahmad committed Dec 2, 2019
1 parent 40e1df7 commit 7e08887
Showing 1 changed file with 47 additions and 8 deletions.
55 changes: 47 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
pg_stat_monitor - Statists collector for [PostgreSQL][1].
pg_stat_monitor - Statistics collector for [PostgreSQL][1].

The pg_stat_monitor is statistics collector tool based on PostgreSQL's pg_stat_statement.
The pg_stat_monitor is statistics collector tool based on PostgreSQL's pg_stat_statement. PostgreSQL’s “pg_stat_statment” provides the basic statistics which is sometimes not enough. The major flaw in this that it accumulates all the queries and its statistics and does not provide aggregate statistics, in that case, the user needs to calculate the aggregate which is quite expensive.

Pg_stat_monitor is build on top of pg_stat_statment, so it provides all the pg_stat_statment plus its own feature set.

#### Supported PostgreSQL Versions.
Pg_stat_monitor should work on the latest version of PostgreSQL but only tested with these versions of PostgreSQL.

* PostgreSQL Version 11
* PostgreSQL Version 12
* Percona Dsitribution for PostgreSQL
* Percona Distribution for PostgreSQL

#### Installation
There are two ways to install the pg_stat_monitor. The first is by downloading the pg_stat_monitor source code and compiling it. The second option is to download the deb or rpm packages.
There are two ways to install pg_stat_monitor. The first is by downloading the pg_stat_monitor source code and compiling it. The second is to download the deb or rpm packages.

##### Download and compile
The latest release of pg_stat_monitor can be downloaded from this GitHub page:

Expand All @@ -18,13 +25,32 @@ or it can be downloaded using the git:

After downloading the code, set the path for the [PostgreSQL][1] binary:

###### Compile
cd pg_stat_monitor
make USE_PGXS=1
make USE_PGXS=1 install

###### Enable Extension
postgres=# alter system set shared_preload_libraries=pg_stat_monitor;
ALTER SYSTEM

sudo systemctl restart postgresql-11

postgres=# create extension pg_stat_monitor;
CREATE EXTENSION


#### Usage
There are four views, and complete statistics can be accessed using these views.

Pg_stat_monitor
Pg_stat_agg_database
Pg_stat_agg_user
pg_stat_agg_hots

##### pg_stat_monitor
This is the main view which stores per query-based statistics, similar to pg_stat_statment with some additional columns.

\d pg_stat_monitor;
View "public.pg_stat_monitor"
Column | Type | Collation | Nullable | Default
Expand Down Expand Up @@ -61,6 +87,19 @@ There are four views, and complete statistics can be accessed using these views.
cpu_user_time | double precision | | |
cpu_sys_time | double precision | | |


These are new column added to have more detail about the query.

host: Client IP or Hostname
hist_calls: Hourly based 24 hours calls of query histogram
hist_min_time: Hourly based 24 hours min time of query histogram
Hist_max_time: Hourly based 24 hours max time of query histogram
hist_mean_time: Hourly based 24 hours mean time of query histogram
slow_query: Slowest query with actual parameters.
cpu_user_time: CPU user time for that query.
cpu_sys_time: CPU System time for that query.


regression=# \d pg_stat_agg_database
View "public.pg_stat_agg_database"
Column | Type | Collation | Nullable | Default
Expand Down Expand Up @@ -131,7 +170,7 @@ There are four views, and complete statistics can be accessed using these views.
slow_query | text | | |

Examples
1 - Here in this query we are getting the exact value of f1 which is '05:06:07-07' in case of slow query.
1 - In this query we are getting the exact value of f1 which is '05:06:07-07' in the case of slow queries.

# select userid, queryid, query, slow_query, max_time, total_calls from pg_stat_agg_user;
-[ RECORD 1 ]----------------------------------------------------------------------------------------
Expand All @@ -142,7 +181,7 @@ Examples
max_time | 1.237875
total_calls | 8

2 - Collect all the statistics based on user.
2 - Collect all statistics based on the 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
Expand All @@ -154,11 +193,11 @@ Examples


#### Limitation
There are some limitations and Todo's.
There are some limitations and Todos.

#### Licence
Copyright (c) 2006 - 2019, Percona LLC.
See [`LICENSE`][2] for full detail
See [`LICENSE`][2] for full details.

[1]: https://www.postgresql.org/
[2]: https://github.com/Percona-Lab/pg_stat_monitor/blob/master/LICENSE
Expand Down

0 comments on commit 7e08887

Please sign in to comment.