{"id":17317231,"url":"https://github.com/rjuju/pg_track_settings","last_synced_at":"2025-08-20T10:32:13.471Z","repository":{"id":26348323,"uuid":"29797223","full_name":"rjuju/pg_track_settings","owner":"rjuju","description":"Small extension to keep track of postgresql settings modification","archived":false,"fork":false,"pushed_at":"2024-11-02T13:20:43.000Z","size":60,"stargazers_count":50,"open_issues_count":0,"forks_count":9,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-12-10T00:42:09.250Z","etag":null,"topics":["extension","monitoring","postgresql"],"latest_commit_sha":null,"homepage":null,"language":"PLpgSQL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"postgresql","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rjuju.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-01-25T00:30:56.000Z","updated_at":"2024-11-02T13:20:47.000Z","dependencies_parsed_at":"2024-06-22T18:37:23.760Z","dependency_job_id":"3a8f16d2-f6fe-4e77-976d-291f0f6ce848","html_url":"https://github.com/rjuju/pg_track_settings","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rjuju%2Fpg_track_settings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rjuju%2Fpg_track_settings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rjuju%2Fpg_track_settings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rjuju%2Fpg_track_settings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rjuju","download_url":"https://codeload.github.com/rjuju/pg_track_settings/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230415318,"owners_count":18222158,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["extension","monitoring","postgresql"],"created_at":"2024-10-15T13:15:56.221Z","updated_at":"2024-12-19T10:09:43.204Z","avatar_url":"https://github.com/rjuju.png","language":"PLpgSQL","funding_links":[],"categories":[],"sub_categories":[],"readme":"pg_track_settings\n=================\n\npg_track_settings is a small extension that helps you keep track of\npostgresql settings configuration.\n\nIt provides a function (**pg_track_settings_snapshot()**), that must be called\nregularly. At each call, it will store the settings that have been changed\nsince last call. It will also track the postgresql start time if it's different\nfrom the last one.\n\nThis extension tracks both overall settings (the **pg_settings** view) and\noverloaded settings (the **pg_db_role_setting** table).\n\nUsage\n-----\n\n- Create the extension in any database:\n\n    CREATE EXTENSION pg_track_settings;\n\nThen make sure the **pg_track_settings_snapshot()** function called. Cron or\nPoWA can be used for that.\n\nFunctions\n---------\n\n- `pg_track_settings_snapshot()`: collect the current settings value.\n- `pg_track_settings(timestamptz)`: return all settings at the specified timestamp. Current time is used if no timestamped specified.\n- `pg_track_settings_diff(timestamptz, timestamptz)`: return all settings that have changed between the two specified timestamps.\n- `pg_track_settings_log(text)`: return the history of a specific setting.\n- `pg_track_db_role_settings(timestamptz)`: return all overloaded settings at the specified timestamp. Current time is used if no timestamped specified.\n- `pg_track_db_role_settings_diff(timestamptz, timestamptz)`: return all overloaded settings that have changed between the two specified timestamps.\n- `pg_track_db_role_settings_log(text)`: return the history of a specific overloaded setting.\n\nExample\n-------\nCall a first time the snapshot function to get the initial values:\n\n    postgres=# select pg_track_settings_snapshot()\n     ----------------------------\n      t\n      (1 row)\n\nA first snapshot is now taken:\n\n     postgres=# select DISTINCT ts FROM pg_track_settings_history ;\n                  ts\n    -------------------------------\n     2015-01-25 01:00:37.449846+01\n     (1 row)\n\nLet's assume the configuration changed, and reload the conf:\n\n    postgres=# select pg_reload_conf();\n     pg_reload_conf\n     ----------------\n      t\n      (1 row)\n\nCall again the snapshot function:\n\n    postgres=# select * from pg_track_settings_snapshot();\n     pg_track_settings_snapshot\n    ----------------------------\n     t\n    (1 row)\n\nNow, we can check what settings changed:\n\n    postgres=# SELECT * FROM pg_track_settings_diff(now() - interval '2 minutes', now());\n            name         | from_setting | from_exists | to_setting | to_exists\n    ---------------------+--------------|-------------|------------|----------\n     checkpoint_segments | 30           | t           | 35         | t\n    (1 row)\n\nAnd the detailed history of this setting:\n\n    postgres=# SELECT * FROM pg_track_settings_log('checkpoint_segments');\n                  ts               |     name            | setting_exists | setting\n    -------------------------------+---------------------+----------------+---------\n     2015-01-25 01:01:42.581682+01 | checkpoint_segments | t              | 35\n     2015-01-25 01:00:37.449846+01 | checkpoint_segments | t              | 30\n    (2 rows)\n\nAnd you can retrieve all the PostgreSQL configuration at a specific timestamp:\n\n\n    postgres=# SELECT * FROM pg_track_settings('2015-01-25 01:01:00');\n                name              | setting\n    ------------------------------+---------\n    [...]\n     checkpoint_completion_target | 0.9\n     checkpoint_segments          | 30\n     checkpoint_timeout           | 300\n    [...]\n\nThe same functions are provided for per role and/or database settings (\n**ALTER ROLE ... SET**, **ALTER ROLE ... IN DATABASE ... SET** and\n**ALTER DATABASE ... SET** commands):\n\n  - pg\\_track\\_db\\_role\\_settings\\_diff()\n  - pg\\_track\\_db\\_role\\_settings\\_log()\n  - pg\\_track\\_db\\_role\\_settings()\n\nWe also have the history of postgres start time:\n\n    postgres=# SELECT * FROM pg_reboot;\n                  ts\n    -------------------------------\n     2015-01-25 00:39:43.609195+01\n    (1 row)\n\nPlease also note that all the history will be saved in a pg\\_dump / pg\\_dumpall\nbackup.  If you need the clear this history, the function\n**pg\\_track\\_settings\\_reset()** will do that for you.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frjuju%2Fpg_track_settings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frjuju%2Fpg_track_settings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frjuju%2Fpg_track_settings/lists"}