{"id":15659526,"url":"https://github.com/idlesign/pg_analyse","last_synced_at":"2025-07-07T06:38:00.732Z","repository":{"id":57452101,"uuid":"246290507","full_name":"idlesign/pg_analyse","owner":"idlesign","description":"Tools to gather useful information from PostgreSQL","archived":false,"fork":false,"pushed_at":"2025-04-16T11:19:16.000Z","size":801,"stargazers_count":21,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-18T12:18:52.114Z","etag":null,"topics":["analyser","indexes","postgresql","python","python3"],"latest_commit_sha":null,"homepage":"https://github.com/idlesign/pg_analyse","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/idlesign.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG","contributing":"CONTRIBUTING","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":"AUTHORS","dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-03-10T12:07:16.000Z","updated_at":"2025-04-16T11:19:19.000Z","dependencies_parsed_at":"2024-11-01T02:03:22.467Z","dependency_job_id":"f84c0dba-55f5-42e2-a50f-5c4039886883","html_url":"https://github.com/idlesign/pg_analyse","commit_stats":{"total_commits":40,"total_committers":3,"mean_commits":"13.333333333333334","dds":0.09999999999999998,"last_synced_commit":"ba0f6fd0e6aa8ca6978055e241c03dd47cf7ce16"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/idlesign/pg_analyse","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idlesign%2Fpg_analyse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idlesign%2Fpg_analyse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idlesign%2Fpg_analyse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idlesign%2Fpg_analyse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/idlesign","download_url":"https://codeload.github.com/idlesign/pg_analyse/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idlesign%2Fpg_analyse/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264029412,"owners_count":23546466,"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":["analyser","indexes","postgresql","python","python3"],"created_at":"2024-10-03T13:17:16.532Z","updated_at":"2025-07-07T06:38:00.725Z","avatar_url":"https://github.com/idlesign.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"pg_analyse\n==========\nhttps://github.com/idlesign/pg_analyse\n\n|release| |lic| |coverage|\n\n.. |release| image:: https://img.shields.io/pypi/v/pg_analyse.svg\n    :target: https://pypi.python.org/pypi/pg_analyse\n\n.. |lic| image:: https://img.shields.io/pypi/l/pg_analyse.svg\n    :target: https://pypi.python.org/pypi/pg_analyse\n\n.. |coverage| image:: https://img.shields.io/coveralls/idlesign/pg_analyse/master.svg\n    :target: https://coveralls.io/r/idlesign/pg_analyse\n\n\n.. image:: https://github.com/idlesign/pg_analyse/blob/master/pg_analyse_cli.gif\n\n\nDescription\n-----------\n\n*Tools to gather useful information from PostgreSQL*\n\nThis package can function both as Python module and as a command line utility.\nCommand line interface can show gathered information in the form of tables or ``JSON``.\n\nUse it to gather information manually or in Continuous Integration.\n\nCan give you some information on:\n\n* Index health (bloat, duplicates, unused, etc.);\n* Tables missing PKs and indexes;\n* Slowest queries.\n\n\n.. note:: SQLs used for inspections are available in https://github.com/mfvanek/pg-index-health-sql\n\n\nRequirements\n------------\n\n* Python 3.10+\n* psycopg 3\n\n\nInstallation\n------------\n\n.. code-block:: bash\n\n    ; If you do not have psycopg3 yet, install it as `psycopg` or `psycopg[binary]`.\n    ; You may also want to install `envbox` to get PG connection settings from .env files.\n    ; Your distribution may require issuing `pip3` command instead of plain `pip`.\n    $ pip install psycopg[binary] envbox\n\n    ; If you want to use it just as Python module:\n    $ pip install pg_analyse\n\n    ; If you want to use it from command line:\n    $ pip install pg_analyse[cli]\n\n\nUsage\n-----\n\nHint\n~~~~\n\nOne can set ``PG_ANALYSE_DSN`` environment variable instead of explicitly passing DSN\nto connect to PostgreSQL. If `envbox \u003chttps://pypi.org/project/envbox/\u003e`_ is installed this\nvariable can be defined in ``.env`` file .\n\nPython module\n~~~~~~~~~~~~~\n\n\n.. code-block:: python\n\n    from pg_analyse.toolbox import Analyser, analyse_and_format\n\n    analyser = Analyser(dsn='user=test')\n\n    inspections = analyser.run()\n    inspection = inspections[0]\n\n    print(inspection.alias)\n    print(inspection.result)\n\n    # Shortcut function is available:\n    out = analyse_and_format()\n\n\nCLI\n~~~\n\n.. code-block:: bash\n\n    ; Show known inspections and descriptions:\n    $ pg_analyse inspections\n\n    ; Use DSN from the environment variable (see hint above),\n    ; print out complex values (e.g. sizes) in human-friendly way:\n    $ pg_analyse run --human\n\n    ; Run certain inspections, override default params.\n    ; Use \"common\" keyword to pass params common for all inspections.\n    $ pg_analyse run --one idx_unused --one idx_bloat --args \"idx_bloat:schema=my,bloat_min=20;common:schema=my\"\n\n    ; Use explicitly passed DSN:\n    $ pg_analyse run --dsn \"host=myhost.net port=6432 user=test password=xxx sslmode=verify-full sslrootcert=/home/my.pem\"\n    ; Local connection as `postgres` user with password:\n    $ pg_analyse run --dsn \"host=127.0.0.1 user=postgres password=yourpass\"\n\n    ; Output analysis result as json (instead of tables):\n    $ pg_analyse run --fmt json\n\n\nAdding Inspections\n------------------\n\nTo add a new inspection to ``pg_analyse``:\n\n1. Compose SQL for inspection and put it into a file under ``sql/`` directory.\n2. Add a subclass of ``Inspection`` into ``inspections/bundled.py``. Fill in ``alias``, ``sql_name`` attributes (see docstrings in ``Inspection``).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidlesign%2Fpg_analyse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fidlesign%2Fpg_analyse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidlesign%2Fpg_analyse/lists"}