All Projects → rjuju → pg_track_settings

rjuju / pg_track_settings

Licence: PostgreSQL License
Small extension to keep track of postgresql settings modification

Programming Languages

PLpgSQL
1095 projects
Makefile
30231 projects

Projects that are alternatives of or similar to pg track settings

Userscript
Userscripts collection written by me
Stars: ✭ 92 (+228.57%)
Mutual labels:  extension
AndrOBD-Plugin
AndrOBD plugin development project
Stars: ✭ 38 (+35.71%)
Mutual labels:  extension
vscode-save-and-run
Visual Studio Code extension to run commands whenever a file is saved https://marketplace.visualstudio.com/items?itemName=wk-j.save-and-run
Stars: ✭ 31 (+10.71%)
Mutual labels:  extension
sanic-mongodb-extension
MongoDB with μMongo support for Sanic framework
Stars: ✭ 25 (-10.71%)
Mutual labels:  extension
vscode-open-in-github
Open the current project or file in github.com.
Stars: ✭ 16 (-42.86%)
Mutual labels:  extension
Visual-Studio
A Discord Rich Presence extension for both Visual Studio 2017 and 2019.
Stars: ✭ 80 (+185.71%)
Mutual labels:  extension
AntiRickRoll
Chrome extension that blocks Rickrolls!
Stars: ✭ 22 (-21.43%)
Mutual labels:  extension
grubreboot-gnome-shell-extension
gnome-shell extension to add a "Reboot" button to the end-session-dialog, that runs grub-reboot before restart
Stars: ✭ 18 (-35.71%)
Mutual labels:  extension
GladiatusCrazyAddon
A browser addon for the Gladiatus browser game.
Stars: ✭ 31 (+10.71%)
Mutual labels:  extension
bana
Set of extensions for Autodesk Maya's Python API.
Stars: ✭ 32 (+14.29%)
Mutual labels:  extension
vscode-magento-wizard
Helps develop Magento 2 extensions using VSCode
Stars: ✭ 22 (-21.43%)
Mutual labels:  extension
AppVeyorExtension
AppVeyor extension for Visual Studio
Stars: ✭ 15 (-46.43%)
Mutual labels:  extension
solidus dev support
A collection of tools for developing Solidus extensions.
Stars: ✭ 14 (-50%)
Mutual labels:  extension
urbit-visor
Urbit Visor is an extension which transforms your web browser into a first class Urbit client.
Stars: ✭ 65 (+132.14%)
Mutual labels:  extension
vscode-note
a simple note-taking extension for vscode.
Stars: ✭ 29 (+3.57%)
Mutual labels:  extension
CSEDevOps
Azure DevOps extensions from CSE DevOps team
Stars: ✭ 18 (-35.71%)
Mutual labels:  extension
spree-postal-service
Weight based calculator for Spree Commerce.
Stars: ✭ 21 (-25%)
Mutual labels:  extension
emulator
Run Android emulator and iOS simulator easily from VScode!
Stars: ✭ 60 (+114.29%)
Mutual labels:  extension
want-my-rss
RSS features for Firefox
Stars: ✭ 68 (+142.86%)
Mutual labels:  extension
fx-private-relay-add-on
Companion add-on for Firefox Relay. Keep your email safe from hackers and trackers. Make an email alias with one click, and keep your address to yourself.
Stars: ✭ 24 (-14.29%)
Mutual labels:  extension

pg_track_settings

pg_track_settings is a small extension that helps you keep track of postgresql settings configuration.

It provides a function (pg_track_settings_snapshot()), that must be called regularly. At each call, it will store the settings that have been changed since last call. It will also track the postgresql start time if it's different from the last one.

This extension tracks both overall settings (the pg_settings view) and overloaded settings (the pg_db_role_setting table).

Usage

  • Create the extension in any database:

    CREATE EXTENSION pg_track_settings;

Then make sure the pg_track_settings_snapshot() function called. Cron or PoWA can be used for that.

Functions

  • pg_track_settings_snapshot(): collect the current settings value.
  • pg_track_settings(timestamptz): return all settings at the specified timestamp. Current time is used if no timestamped specified.
  • pg_track_settings_diff(timestamptz, timestamptz): return all settings that have changed between the two specified timestamps.
  • pg_track_settings_log(text): return the history of a specific setting.
  • pg_track_db_role_settings(timestamptz): return all overloaded settings at the specified timestamp. Current time is used if no timestamped specified.
  • pg_track_db_role_settings_diff(timestamptz, timestamptz): return all overloaded settings that have changed between the two specified timestamps.
  • pg_track_db_role_settings_log(text): return the history of a specific overloaded setting.

Example

Call a first time the snapshot function to get the initial values:

postgres=# select pg_track_settings_snapshot()
 ----------------------------
  t
  (1 row)

A first snapshot is now taken:

 postgres=# select DISTINCT ts FROM pg_track_settings_history ;
              ts
-------------------------------
 2015-01-25 01:00:37.449846+01
 (1 row)

Let's assume the configuration changed, and reload the conf:

postgres=# select pg_reload_conf();
 pg_reload_conf
 ----------------
  t
  (1 row)

Call again the snapshot function:

postgres=# select * from pg_track_settings_snapshot();
 pg_track_settings_snapshot
----------------------------
 t
(1 row)

Now, we can check what settings changed:

postgres=# SELECT * FROM pg_track_settings_diff(now() - interval '2 minutes', now());
        name         | from_setting | from_exists | to_setting | to_exists
---------------------+--------------|-------------|------------|----------
 checkpoint_segments | 30           | t           | 35         | t
(1 row)

And the detailed history of this setting:

postgres=# SELECT * FROM pg_track_settings_log('checkpoint_segments');
              ts               |     name            | setting_exists | setting
-------------------------------+---------------------+----------------+---------
 2015-01-25 01:01:42.581682+01 | checkpoint_segments | t              | 35
 2015-01-25 01:00:37.449846+01 | checkpoint_segments | t              | 30
(2 rows)

And you can retrieve all the PostgreSQL configuration at a specific timestamp:

postgres=# SELECT * FROM pg_track_settings('2015-01-25 01:01:00');
            name              | setting
------------------------------+---------
[...]
 checkpoint_completion_target | 0.9
 checkpoint_segments          | 30
 checkpoint_timeout           | 300
[...]

The same functions are provided for per role and/or database settings ( ALTER ROLE ... SET, ALTER ROLE ... IN DATABASE ... SET and ALTER DATABASE ... SET commands):

  • pg_track_db_role_settings_diff()
  • pg_track_db_role_settings_log()
  • pg_track_db_role_settings()

We also have the history of postgres start time:

postgres=# SELECT * FROM pg_reboot;
              ts
-------------------------------
 2015-01-25 00:39:43.609195+01
(1 row)

Please also note that all the history will be saved in a pg_dump / pg_dumpall backup. If you need the clear this history, the function pg_track_settings_reset() will do that for you.

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