All Projects → percona → Pg_stat_monitor

percona / Pg_stat_monitor

Licence: other
PostgreSQL Statistics Collector

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Pg stat monitor

Go Cache
This project encapsulates multiple db servers, redis、ledis、memcache、file、memory、nosql、postgresql
Stars: ✭ 143 (-1.38%)
Mutual labels:  postgresql, postgres
Timescaledb
An open-source time-series SQL database optimized for fast ingest and complex queries. Packaged as a PostgreSQL extension.
Stars: ✭ 12,211 (+8321.38%)
Mutual labels:  postgresql, postgres
Postgresqlcopyhelper
Simple Wrapper around Npgsql for using PostgreSQL COPY functions.
Stars: ✭ 120 (-17.24%)
Mutual labels:  postgresql, postgres
Pgcmd
Non-interactive PostgreSQL query tool.
Stars: ✭ 117 (-19.31%)
Mutual labels:  postgresql, postgres
Ozo
OZO is a C++17 Boost.Asio based header-only library for asyncronous communication with PostgreSQL DBMS.
Stars: ✭ 138 (-4.83%)
Mutual labels:  postgresql, postgres
Calculate All
calculate_all method for aggregate functions in Active Record
Stars: ✭ 118 (-18.62%)
Mutual labels:  statistics, postgres
Postgres Showcase
Postgres features showcase (commented SQL samples) for beginners
Stars: ✭ 121 (-16.55%)
Mutual labels:  postgresql, postgres
Postgres Checkup
Postgres Health Check and SQL Performance Analysis. 👉 THIS IS A MIRROR OF https://gitlab.com/postgres-ai/postgres-checkup
Stars: ✭ 110 (-24.14%)
Mutual labels:  postgresql, postgres
Masquerade
A Postgres Proxy to Mask Data in Realtime
Stars: ✭ 134 (-7.59%)
Mutual labels:  postgresql, postgres
Postgres Operator
Postgres operator creates and manages PostgreSQL clusters running in Kubernetes
Stars: ✭ 2,194 (+1413.1%)
Mutual labels:  postgresql, postgres
Postgraphile
GraphQL is a new way of communicating with your server. It eliminates the problems of over- and under-fetching, incorporates strong data types, has built-in introspection, documentation and deprecation capabilities, and is implemented in many programming languages. This all leads to gloriously low-latency user experiences, better developer experiences, and much increased productivity. Because of all this, GraphQL is typically used as a replacement for (or companion to) RESTful API services.
Stars: ✭ 10,967 (+7463.45%)
Mutual labels:  postgresql, postgres
Serverless Pg
A package for managing PostgreSQL connections at SERVERLESS scale
Stars: ✭ 142 (-2.07%)
Mutual labels:  postgresql, postgres
Ship Hold
data access framework for Postgresql on nodejs
Stars: ✭ 110 (-24.14%)
Mutual labels:  postgresql, postgres
Symfony 4 Docker Env
Docker Environment for Symfony. PHP-FPM, NGINX SSL Proxy, MySQL, LEMP
Stars: ✭ 119 (-17.93%)
Mutual labels:  postgresql, postgres
Libpq.jl
A Julia wrapper for libpq
Stars: ✭ 109 (-24.83%)
Mutual labels:  postgresql, postgres
Tunnel
PG数据同步工具(Java实现)
Stars: ✭ 122 (-15.86%)
Mutual labels:  postgresql, postgres
Activerecord Clean Db Structure
Automatic cleanup for the Rails db/structure.sql file (ActiveRecord/PostgreSQL)
Stars: ✭ 101 (-30.34%)
Mutual labels:  postgresql, postgres
Pg flame
A flamegraph generator for Postgres EXPLAIN ANALYZE output.
Stars: ✭ 1,391 (+859.31%)
Mutual labels:  postgresql, postgres
Postgres Operator
Production PostgreSQL for Kubernetes, from high availability Postgres clusters to full-scale database-as-a-service.
Stars: ✭ 2,166 (+1393.79%)
Mutual labels:  postgresql, postgres
Wal G
Archival and Restoration for Postgres
Stars: ✭ 1,974 (+1261.38%)
Mutual labels:  postgresql, postgres

pg11-test pg12-test pg13-test

What is pg_stat_monitor?

The pg_stat_monitor is a PostgreSQL Query Performance Monitoring tool, based on PostgreSQL's contrib module pg_stat_statements. PostgreSQL’s pg_stat_statements provides the basic statistics, which is sometimes not enough. The major shortcoming in pg_stat_statements is that it accumulates all the queries and their statistics and does not provide aggregated statistics nor histogram information. In this case, a user needs to calculate the aggregate which is quite expensive.

pg_stat_monitor is developed on the basis of pg_stat_statements as its more advanced replacement. It provides all the features of pg_stat_statements plus its own feature set.

How pg_stat_monitor works?

pg_stat_monitor accumulates the information in the form of buckets. All the aggregated information is bucket based. The size of a bucket and the number of buckets should be configured using GUC (Grand Unified Configuration). When a bucket time elapses, pg_stat_monitor resets all the statistics and switches to the next bucket. After the last bucket elapses, pg_stat_monitor goes back to the first bucket. All the data on the first bucket will vanish; therefore, users must read the buckets before that to not lose the data.

Documentation

  1. Supported PostgreSQL Versions
  2. Installation
  3. Setup
  4. User Guide
  5. Release Notes
  6. License
  7. Submitting Bug Reports
  8. Copyright Notice

Supported PostgreSQL Versions

The pg_stat_monitor should work on the latest version of PostgreSQL but is only tested with these PostgreSQL versions:

Distribution Version Supported
PostgreSQL Version < 11
PostgreSQL Version 11 ✔️
PostgreSQL Version 12 ✔️
PostgreSQL Version 13 ✔️
Percona Distribution Version < 11
Percona Distribution Version 11 ✔️
Percona Distribution Version 12 ✔️
Percona Distribution Version 13 ✔️

Installation

pg_stat_monitor is supplied as part of Percona Distribution for PostgreSQL. The rpm/deb packages are available from Percona repositories. Refer to Percona Documentation for installation instructions.

Installing from PGXN

You can install pg_stat_monitor from PGXN (PostgreSQL Extensions Network) using the PGXN client.

Use the following command:

pgxn install pg_stat_monitor

Installing from source code

You can download the source code of the latest release of pg_stat_monitor from this GitHub page or using git:

git clone git://github.com/Percona/pg_stat_monitor.git

Compile and install the extension

cd pg_stat_monitor
make USE_PGXS=1
make USE_PGXS=1 install

Setup

pg_stat_monitor cannot be enabled in your running PostgreSQL instance. pg_stat_monitor needs to be loaded at the start time. This requires adding the pg_stat_monitor extension for the shared_preload_libraries parameter and restarting the PostgreSQL instance.

You can set the pg_stat_monitor extension in the postgresql.conf file.

# - Shared Library Preloading -

shared_preload_libraries = 'pg_stat_monitor' # (change requires restart)
#local_preload_libraries = ''
#session_preload_libraries = ''

Or you can set it from psql terminal using the alter system command.

ALTER SYSTEM SET shared_preload_libraries = 'pg_stat_monitor';
ALTER SYSTEM
sudo systemctl restart postgresql-13

Create the extension using the CREATE EXTENSION command.

CREATE EXTENSION pg_stat_monitor;
CREATE EXTENSION
-- Select some of the query information, like client_ip, username and application_name etc.

postgres=# SELECT application_name, userid AS user_name, datname AS database_name, substr(query,0, 50) AS query, calls, client_ip 
           FROM pg_stat_monitor;
 application_name | user_name | database_name |                       query                       | calls | client_ip 
------------------+-----------+---------------+---------------------------------------------------+-------+-----------
 psql             | vagrant   | postgres      | SELECT application_name, userid::regrole AS user_ |     1 | 127.0.0.1
 psql             | vagrant   | postgres      | SELECT application_name, userid AS user_name, dat |     3 | 127.0.0.1
 psql             | vagrant   | postgres      | SELECT application_name, userid AS user_name, dat |     1 | 127.0.0.1
 psql             | vagrant   | postgres      | SELECT application_name, userid AS user_name, dat |     8 | 127.0.0.1
 psql             | vagrant   | postgres      | SELECT bucket, substr(query,$1, $2) AS query, cmd |     1 | 127.0.0.1
(5 rows)


-- Select queries along with elevel, message and sqlcode which have some errors.

SELECT  decode_error_level(elevel) AS elevel, sqlcode, query, message FROM pg_stat_monitor WHERE elevel != 0;
 elevel.   | sqlcode |                                           query                                           |                    message                     
--------------------+---------+-------------------------------------------------------------------------------------------+------------------------------------------------
 ERROR     |     132 | select count(*) from pgbench_branches                                                     | permission denied for table pgbench_branches
 ERROR     |     130 | select 1/0;                                                                               | division by zero
 ERROR     |     132 | SELECT decode_elevel(elevel), sqlcode, message from pg_stat_monitor where elevel != 0;    | function decode_elevel(integer) does not exist
 ERROR     |     132 | drop table if exists pgbench_accounts, pgbench_branches, pgbench_history, pgbench_tellers | must be owner of table pgbench_accounts
(4 rows)

To learn more about pg_stat_monitor configuration and usage, see User Guide.

Submitting Bug Reports

If you found a bug in pg_stat_monitor, please submit the report to the Jira issue tracker

Start by searching the open tickets for a similar report. If you find that someone else has already reported your issue, then you can upvote that report to increase its visibility.

If there is no existing report, submit your report following these steps:

Sign in to Jira issue tracker. You will need to create an account if you do not have one.

In the Summary, Description, Steps To Reproduce, Affects Version fields describe the problem you have detected.

As a general rule of thumb, try to create bug reports that are:

  • Reproducible: describe the steps to reproduce the problem.

  • Unique: check if there already exists a JIRA ticket to describe the problem.

  • Scoped to a Single Bug: only report one bug in one JIRA ticket.

Copyright Notice

Portions Copyright © 2018-2020, Percona LLC and/or its affiliates

Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group

Portions Copyright (c) 1994, The Regents of the University of California

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].