{"id":13707539,"url":"https://github.com/awslabs/pg-collector","last_synced_at":"2025-05-06T03:32:28.667Z","repository":{"id":37868534,"uuid":"321153702","full_name":"awslabs/pg-collector","owner":"awslabs","description":"PG Collector for Postgresql is a sql script that gathers valuable database information and presents it in a consolidated HTML file which provides a convenient way to view and navigate between different sections of the report","archived":false,"fork":false,"pushed_at":"2024-12-10T17:29:25.000Z","size":720,"stargazers_count":102,"open_issues_count":5,"forks_count":24,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-19T10:16:26.936Z","etag":null,"topics":["pg-collector","postgres","postgresql","sql-script","vacuum"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit-0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/awslabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2020-12-13T20:27:55.000Z","updated_at":"2025-04-09T07:28:53.000Z","dependencies_parsed_at":"2024-11-13T16:36:30.235Z","dependency_job_id":"4bf8242e-2c08-4257-b29c-2fdf9fd7f4dc","html_url":"https://github.com/awslabs/pg-collector","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awslabs%2Fpg-collector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awslabs%2Fpg-collector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awslabs%2Fpg-collector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awslabs%2Fpg-collector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/awslabs","download_url":"https://codeload.github.com/awslabs/pg-collector/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252616764,"owners_count":21777051,"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":["pg-collector","postgres","postgresql","sql-script","vacuum"],"created_at":"2024-08-02T22:01:34.606Z","updated_at":"2025-05-06T03:32:28.660Z","avatar_url":"https://github.com/awslabs.png","language":"HTML","funding_links":[],"categories":["HTML"],"sub_categories":[],"readme":"# PG Collector  \u003cimg src=\"img/pg_collector_logo.png\" align=\"right\" alt=\"\"\u003e\n\n## Overview\n\nPG Collector for [Postgresql](https://www.postgresql.org/) is a sql script that gathers valuable database information and presents it in a consolidated HTML file which provides a convenient way to view and navigate between different sections of the report.\n\nPG Collector is safe to run on production environments and does not create any database objects to produce the output.\n\nWith PG Collector an operator gains insights on various aspects of the database, such as:\n* Database size\n* Configuration parameters\n* Installed extensions\n* Vacuum \u0026 Statistics\n* Unused Indexes \u0026 invalid indexes\n* Users \u0026 Roles Info\n* Toast Tables Mapping\n* Database schemas \n* Fragmentation (Bloat)\n* Tablespaces Info\n* Memory setting\n* Tables and Indexes Size and info\n* Transaction ID\n* Replication slots\n* public Schema info \n* Unlogged Tables\n\nand more, please check the example reports \n\n## Versioning Policy :\n\nStarting from PostgreSQL 13, PG Collector will have a dedicated script for each PostgreSQL major version .\n\neach PG Collector major version will have it is own branch and the main branch will be for PG Collector that support PostgreSQL 12 and older versions \n\n\u003cimg src=\"img/PG_Collector_branches.png\" alt=\"\"\u003e\n\n## How to download PG Collector that match your PostgreSQL major version ?\n\nFrom [pg-collector releases](https://github.com/awslabs/pg-collector/releases)\n\nselect PG Collector version that match your PostgreSQL major version \n\n\u003cimg src=\"img/pg_collector_releases_1.png\" alt=\"\"\u003e\n\u003cimg src=\"img/pg_collector_releases_2.png\" alt=\"\"\u003e\n\n## How to check PG Collector version ?\n\n- from the PG Collector report header  \n\u003cimg src=\"img/PG_Collector_report_header_version.png\" alt=\"\"\u003e\n\n- from the PG Collector script header\n\u003cimg src=\"img/PG_Collector_script_header.png\" alt=\"\"\u003e \n\n## PG Collector report header \n\u003cimg src=\"img/pg_collector_header_V2.6.png\" alt=\"\"\u003e\n\n\n\n## Example of PG Collector report \n\n[pg_collector v2.9](http://pg-collector.s3-website-us-west-2.amazonaws.com/pg_collector_postgres-2021-08-02_181348.html)\n\n[pg_collector v2.7](http://pg-collector.s3-website-us-west-2.amazonaws.com/pg_collector_postgres-2020-12-14_053537.html)\n\nAll Sample reports in [sample report folder](https://github.com/awslabs/pg-collector/tree/main/sample_reports).\n\n\n## PG Collector output\n\n### Report name:\nPG Collector script will generate HTML file using the following naming convention pg_colletcor_[DB Name]-[timestamp].html .\n\n[DB Name] : is the database name that you are connected to.\n\n```\nExample : pg_collector_testdb-2020-10-10_030920.html\n```\n\n\n### Report location: \nPG Collector script will generate HTML file  under [/tmp](https://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/tmp.html) directory. \n\n\n\n## How to run PG Collector script ( pg_collector.sql )\n\n1- you need [psql](https://www.postgresql.org/docs/10/app-psql.html) to be able to connect to the postgresql DB and run the pg_collector.sql script \n\n2- Download pg_collector.sql in your laptop or the host that want to access the database from \n\n3- login to the database using psql \n```\npsql -h [hostname or RDS endpoint] -p [Port] -d [Database name ] -U [user name] \n```\n4- run the pg_collector.sql script \n\n```\n\\i pg_collector.sql \n\\q\n```\nor use -f option in psql \n\n```\npsql -h [hostname or RDS endpoint] -p [Port] -d [Database name ] -U [user name] -f pg_collector.sql \n```\n\nExample :\n\n```\nmohamed@mydevhost ~ % psql -h testdb-instance-1.cimdlffuw.us-west-2.rds.amazonaws.com -p 5432 -d testdb -U mohamed\npsql (9.4.8, server 10.6)\nWARNING: psql major version 9.4, server major version 10.6.\n         Some psql features might not work.\nSSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)\nType \"help\" for help.\n\ntestdb=\u003e \\i pg_collector.sql\nOutput format is html.\nDefault footer is off.\ntestdb=\u003e \\q\nmohamed@mydevhost ~ %ls -lhrt /tmp/pg_colletcor_*\n-rw-r--r-- 1 mohamed mohamed 569K Oct  7 21:51 /tmp/pg_colletcor_testdb-2019-10-07_215146.html\n\n```\n5-  open the report using any internet browser\n\n\n\n## Notes:\n1- It is ok to see below errors while executing the pg_colletcor.sql script if you did not install pg_stat_statements extension\n\n```\npostgres=\u003e \\i pg_collector.sql\nOutput format is html.\nDefault footer is off.\npsql:pg_collector.sql:481: ERROR:  relation \"pg_stat_statements\" does not exist\nLINE 10: from pg_stat_statements\n              ^\npsql:pg_collector.sql:495: ERROR:  relation \"pg_stat_statements\" does not exist\nLINE 10: from pg_stat_statements\n              ^\npsql:pg_collector.sql:509: ERROR:  relation \"pg_stat_statements\" does not exist\nLINE 10: from pg_stat_statements\n              ^\npsql:pg_collector.sql:523: ERROR:  relation \"pg_stat_statements\" does not exist\nLINE 10: from pg_stat_statements\n              ^\npostgres=\u003e \\q\n```\n\n2- If the Database have Tens of thousands of tables , some queries can take longer time .\nuse statement_timeout to Abort any statement that takes more than the specified number of milliseconds.\nplease check below example .  \n\n\n```\npostgres=\u003e set statement_timeout=30000;\nSET\npostgres=\u003e \\i pg_collector.sql\nOutput format is html.\nReport name and location: /tmp/pg_collector_postgres-2021-07-22_194944.html\npsql:pg_collector.sql:1442: ERROR:  canceling statement due to statement timeout\npostgres=\u003e\n\n```\n\n3- It is acceptable to observe the following errors while executing the pg_collector.sql script on Amazon Aurora PostgreSQL if the Cluster Cache Manager is disabled.\n\n```\npostgres=\u003e \\i pg_collector.sql\nOutput format is html.\npsql:/tmp/pg_collector.sql:2766: ERROR: Cluster Cache Manager is disabled\npsql:/tmp/pg_collector.sql:2769: ERROR: Cluster Cache Manager is disabled\nReport Generated Successfully\nReport name and location: /tmp/pg_collector_postgres-2024-09-09_161216.html\n\n```\n\n# License\n\nThis library is licensed under the MIT-0 License. See the LICENSE file.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawslabs%2Fpg-collector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fawslabs%2Fpg-collector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawslabs%2Fpg-collector/lists"}