{"id":13566638,"url":"https://github.com/pgexperts/pgx_scripts","last_synced_at":"2025-04-08T09:06:40.532Z","repository":{"id":21692317,"uuid":"25013630","full_name":"pgexperts/pgx_scripts","owner":"pgexperts","description":"A collection of useful little scripts for database analysis and administration, created by our team at PostgreSQL Experts.","archived":false,"fork":false,"pushed_at":"2023-08-10T22:34:00.000Z","size":71,"stargazers_count":1412,"open_issues_count":8,"forks_count":239,"subscribers_count":111,"default_branch":"master","last_synced_at":"2025-04-01T07:45:09.972Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pgexperts.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2014-10-10T00:09:58.000Z","updated_at":"2025-03-28T18:17:54.000Z","dependencies_parsed_at":"2022-08-02T20:30:52.560Z","dependency_job_id":"f09f043b-2aca-42e9-9d58-d310f7b8e8b6","html_url":"https://github.com/pgexperts/pgx_scripts","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgexperts%2Fpgx_scripts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgexperts%2Fpgx_scripts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgexperts%2Fpgx_scripts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgexperts%2Fpgx_scripts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pgexperts","download_url":"https://codeload.github.com/pgexperts/pgx_scripts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247809964,"owners_count":20999816,"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":[],"created_at":"2024-08-01T13:02:13.715Z","updated_at":"2025-04-08T09:06:40.509Z","avatar_url":"https://github.com/pgexperts.png","language":"Shell","funding_links":[],"categories":["Shell","others","Compiled list","SQL"],"sub_categories":["plv8:","Scripts"],"readme":"pgx_scripts\n===========\n\nA collection of useful little scripts for database analysis and administration, created by our team at PostgreSQL Experts.\n\nbloat\n=====\n\nQueries to estimate bloat in tables and indexes.\n\nindex_bloat_check.sql\n---------------------\n\nAn overhauled index bloat check.  Lists indexes which are likely to be bloated and estimates bloat amounts.  Requires PostgreSQL \u003e 8.4, superuser access, and a 64-bit compile.  Only works for BTree indexes, not GIN, GiST, or more exotic indexes.  Still needs cleanup.\n\ntable_bloat_check.sql\n---------------------\n\nAn overhauled table bloat check.  Lists tables which are likely to be bloated and estimates bloat amounts.  Requires PostgreSQL \u003e= 8.4 and a 64-bit compile.  Cannot estimate bloat for tables containing types with no stats functions (such as original JSON).\n\nno_stats_table_check.sql\n------------------------\n\nQuery to list all tables which have \"no stats\" columns and thus can't be estimated.\n\n\nkill_idle\n=========\n\nkill_idle_91.sql\n----------------\n\nA stored procedure which kills idle transactions on PostgreSQL versions 8.3 to 9.1.  Intended to be called by a cron job.  Takes idle time, polling time, and exempted user list parameters.  Outputs pipe-delimited text with the data about the sessions killed.\n\nkill_idle_93.sql\n----------------\n\nA stored procedure which kills idle transactions on PostgreSQL versions 9.2 and later.  Intended to be called by a cron job.  Takes idle time and exempted user list parameters.  Outputs JSON with the data about the sessions killed.\n\nIndexes\n=======\n\nVarious queries to introspect index usage.\n\nfk_no_index.sql\n---------------\n\nQueries for foreign keys with no index on the referencing side.  Note that you don't always want indexes on the referencing side, but this helps you decide if you do.\n\nduplicate_indexes_fuzzy.sql\n---------------------------\n\nCheck indexes and looks at whether or not they are potentially duplicates.  It does this by checking the columns used by each index, so it reports lots of false duplicates for partial and functional indexes.\n\nneeded_indexes.sql\n------------------\n\nChecks for tables which are getting too much sequential scan activity and might need additional indexing.  Reports in four groups based on table size, number of scans, write activity, and number of existing indexes.\n\nunneeded_indexes.sql\n--------------------\n\nChecks for indexes with relatively light usage stats, for possible removal.\n\nLocks\n=====\n\nTools and a set of queries to analyze lock-blocking.\n\ntransaction_locks.sql\n---------------------\n\nRequires: Postgres 9.2+\n\nLists waiting transaction locks and what they're waiting on, if possible.\nIncludes relation and query information, but realistically needs to be\naccompanied by full query logging to be useful.  Needs to be run\nper active database.\n\ntable_locks.sql\n---------------\n\nLists direct locks on tables which conflict with locks held by other sessions.  Note that table\nlocks are often short-lived, and as a result this will often result in zero rows.\n\n\nAdditional Contributors\n=======================\n\nIn addition to the staff of PostgreSQL Experts, we are indebted\nto:\n\n* The authors of the check_postgres.pl script, especially \n  Greg Sabino Mulainne, for supplying the\n  original bloat queries on which our bloat queries are based.\n* Andrew Gierth for help on various system queries.\n* ioguix for collaborating on bloat calculation math.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgexperts%2Fpgx_scripts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpgexperts%2Fpgx_scripts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgexperts%2Fpgx_scripts/lists"}