All Projects → postgrespro → Pg_wait_sampling

postgrespro / Pg_wait_sampling

Licence: other
Sampling based statistics of wait events

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Pg wait sampling

Rpg Boilerplate
Relay (React), Postgres, and Graphile (GraphQL): A Modern Frontend and API Boilerplate
Stars: ✭ 62 (-23.46%)
Mutual labels:  postgres
Osmium
Online collaborative fitting tool.
Stars: ✭ 74 (-8.64%)
Mutual labels:  postgres
Go Dberror
parsing postgres errors
Stars: ✭ 78 (-3.7%)
Mutual labels:  postgres
Route
原生 js 实现的轻量级路由,且页面跳转间有缓存功能。
Stars: ✭ 68 (-16.05%)
Mutual labels:  history
Ebean
Ebean ORM
Stars: ✭ 1,172 (+1346.91%)
Mutual labels:  postgres
Plv8
V8 Engine Javascript Procedural Language add-on for PostgreSQL
Stars: ✭ 1,195 (+1375.31%)
Mutual labels:  postgres
Stackexchange Dump To Postgres
Python scripts to import StackExchange data dump into Postgres DB.
Stars: ✭ 58 (-28.4%)
Mutual labels:  postgres
Bartlett
A simple Jenkins command line client to serve your needs.
Stars: ✭ 81 (+0%)
Mutual labels:  profile
Method log
Trace the history of an individual method in a git repository (experimental)
Stars: ✭ 73 (-9.88%)
Mutual labels:  history
Blindchat
a facebook messenger bot that allows users to chat with other people on facebook anonymously
Stars: ✭ 78 (-3.7%)
Mutual labels:  postgres
Escpos Printer Db
Database of ESC/POS thermal receipt printers
Stars: ✭ 68 (-16.05%)
Mutual labels:  profile
Profile Card
Tailwind CSS Starter Template - Profile Card (Single page website for your profile/links)
Stars: ✭ 69 (-14.81%)
Mutual labels:  profile
Bgworker
Background Worker Processes for PostgreSQL written in Go
Stars: ✭ 77 (-4.94%)
Mutual labels:  postgres
Pgstore
A Postgres session store backend for gorilla/sessions
Stars: ✭ 66 (-18.52%)
Mutual labels:  postgres
Pgdump Aws Lambda
Lambda function for executing pg_dump and streaming the output to s3.
Stars: ✭ 80 (-1.23%)
Mutual labels:  postgres
Skunk
A data access library for Scala + Postgres.
Stars: ✭ 1,107 (+1266.67%)
Mutual labels:  postgres
Vip Manager
Manages a virtual IP based on state kept in etcd or Consul
Stars: ✭ 75 (-7.41%)
Mutual labels:  postgres
Sql
MySQL & PostgreSQL pipe
Stars: ✭ 81 (+0%)
Mutual labels:  postgres
Calendarsyncplus
This utility synchronizes Calendar entries between different calendar providers (Apps like Outlook,Services EWS/Google/Live).
Stars: ✭ 80 (-1.23%)
Mutual labels:  profile
Repmgr
A lightweight replication manager for PostgreSQL (Postgres) - latest version 5.2.1 (2020-12-07)
Stars: ✭ 1,207 (+1390.12%)
Mutual labels:  postgres

Build Status PGXN version GitHub license

pg_wait_sampling – sampling based statistics of wait events

Introduction

PostgreSQL 9.6+ provides an information about current wait event of particular process. However, in order to gather descriptive statistics of server behavior user have to sample current wait event multiple times. pg_wait_sampling is an extension for collecting sampling statistics of wait events.

The module must be loaded by adding pg_wait_sampling to shared_preload_libraries in postgresql.conf, because it requires additional shared memory and launches background worker. This means that a server restart is needed to add or remove the module.

When pg_wait_sampling is enabled, it collects two kinds of statistics.

  • History of waits events. It's implemented as in-memory ring buffer where samples of each process wait events are written with given (configurable) period. Therefore, for each running process user can see some number of recent samples depending on history size (configurable). Assuming there is a client who periodically read this history and dump it somewhere, user can have continuous history.
  • Waits profile. It's implemented as in-memory hash table where count of samples are accumulated per each process and each wait event (and each query with pg_stat_statements). This hash table can be reset by user request. Assuming there is a client who periodically dumps profile and resets it, user can have statistics of intensivity of wait events among time.

In combination with pg_stat_statements this extension can also provide per query statistics.

pg_wait_sampling launches special background worker for gathering the statistics above.

Availability

pg_wait_sampling is implemented as an extension and not available in default PostgreSQL installation. It is available from github under the same license as PostgreSQL and supports PostgreSQL 9.6+.

Installation

pg_wait_sampling is PostgreSQL extension which requires PostgreSQL 9.6 or higher. Before build and install you should ensure following:

  • PostgreSQL version is 9.6 or higher.
  • You have development package of PostgreSQL installed or you built PostgreSQL from source.
  • Your PATH variable is configured so that pg_config command available, or set PG_CONFIG variable.

Typical installation procedure may look like this:

$ git clone https://github.com/postgrespro/pg_wait_sampling.git
$ cd pg_wait_sampling
$ make USE_PGXS=1
$ sudo make USE_PGXS=1 install
$ make USE_PGXS=1 installcheck
$ psql DB -c "CREATE EXTENSION pg_wait_sampling;"

Compilation on Windows is not supported, since the extension uses symbols from PostgreSQL that are not exported.

Usage

pg_wait_sampling interacts with user by set of views and functions.

pg_wait_sampling_current view – information about current wait events for all processed including background workers.

Column name Column type Description
pid int4 Id of process
event_type text Name of wait event type
event text Name of wait event
queryid int8 Id of query

pg_wait_sampling_get_current(pid int4) returns the same table for single given process.

pg_wait_sampling_history view – history of wait events obtained by sampling into in-memory ring buffer.

Column name Column type Description
pid int4 Id of process
ts timestamptz Sample timestamp
event_type text Name of wait event type
event text Name of wait event
queryid int8 Id of query

pg_wait_sampling_profile view – profile of wait events obtained by sampling into in-memory hash table.

Column name Column type Description
pid int4 Id of process
event_type text Name of wait event type
event text Name of wait event
queryid int8 Id of query
count text Count of samples

pg_wait_sampling_reset_profile() function resets the profile.

The work of wait event statistics collector worker is controlled by following GUCs.

Parameter name Data type Description Default value
pg_wait_sampling.history_size int4 Size of history in-memory ring buffer 5000
pg_wait_sampling.history_period int4 Period for history sampling in milliseconds 10
pg_wait_sampling.profile_period int4 Period for profile sampling in milliseconds 10
pg_wait_sampling.profile_pid bool Whether profile should be per pid true
pg_wait_sampling.profile_queries bool Whether profile should be per query false

If pg_wait_sampling.profile_pid is set to false, sampling profile wouldn't be collected in per-process manner. In this case the value of pid could would be always zero and corresponding row contain samples among all the processes.

While pg_wait_sampling.profile_queries is set to false queryid field in views will be zero.

These GUCs are allowed to be changed by superuser. Also, they are placed into shared memory. Thus, they could be changed from any backend and affects worker runtime.

See PostgreSQL documentation for list of possible wait events.

Contribution

Please, notice, that pg_wait_sampling is still under development and while it's stable and tested, it may contains some bugs. Don't hesitate to raise issues at github with your bug reports.

If you're lacking of some functionality in pg_wait_sampling and feeling power to implement it then you're welcome to make pull requests.

Releases

New features are developed in feature-branches and then merged into master. To make a new release:

  1. Bump PGXN version in the META.json.
  2. Merge master into stable.
  3. Tag new release in the stable with git tag -a v1.1.X, where the last digit is used for indicating compatible shared library changes and bugfixes. Second digit is used to indicate extension schema change, i.e. when ALTER EXTENSION pg_wait_sampling UPDATE; is required.
  4. Merge stable into debian. This separate branch is used to independently support Debian packaging and @anayrat with @df7cb have an access there.

Authors

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].