{ "info": { "author": "Scott Woodall", "author_email": "scott.woodall@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3" ], "description": "===============\npython-pgextras\n===============\n\n.. image:: https://badge.fury.io/py/pgextras.png\n :target: http://badge.fury.io/py/pgextras\n\n.. image:: https://travis-ci.org/scottwoodall/python-pgextras.png?branch=master\n :target: https://travis-ci.org/scottwoodall/python-pgextras\n\n.. image:: https://pypip.in/d/pgextras/badge.png\n :target: https://pypi.python.org/pypi/pgextras\n\n.. image:: https://coveralls.io/repos/scottwoodall/python-pgextras/badge.png\n :target: https://coveralls.io/r/scottwoodall/python-pgextras\n\n\nUnofficial Python port of `Heroku's pgextras `_\nthat provides various statistics for a Postgres instance. The biggest difference\nof this module is that your Postgres database can be anywhere, not just\nhosted with Heroku.\n\n* BSD license\n* Tested against 2.7 and 3.3\n* `Documentation `_\n* `Github `_\n\nFeatures\n########\n\nNote: pgextras does not format the output as seen in all the examples below. Instead it\nreturns an iterable that contains namedtuples. For example, the \"Total Indexes Size\"\nmethod returns the following::\n\n [\n Record(table='pgbench_accounts', index_size='2208 kB'),\n Record(table='pgbench_tellers', index_size='16 kB'),\n Record(table='pgbench_branches', index_size='16 kB'),\n Record(table='pgbench_history', index_size='0 bytes')\n ]\n\nIt's up to you on how to format and present the data. The results below are\nformatted to make it easier to understand the data available to you.\n\nDev Install\n###########\n\nThis is specific to the ::\n update-sql-statements branch\nClone the repository and change the branch to `update-sql-statements`\ncd in to the directory and run ::\n python setup.py install\nThis should install the pgextras exectutable\n\nNow, you can use any postgres database to run pgextras\n\n\nCache Hit\n*********\nCalculates your cache hit rate (effective databases are at 99% and up)::\n\n | name | ratio |\n |----------------+----------|\n | index hit rate | 0.999888 |\n | table hit rate | 0.999696 |\n\nIndex Usage\n***********\nCalculates your index hit rate (effective databases are at 99% and up)::\n\n | relname | percent_of_times_index_used | rows_in_table |\n |------------------+-------------------------------+-----------------|\n | pgbench_history | | 149985 |\n | pgbench_accounts | 99 | 100000 |\n | pgbench_tellers | 96 | 10 |\n | pgbench_branches | 93 | 1 |\n\nCalls\n*****\nShow 10 most frequently called queries::\n\n | qry | exec_time | prop_exec_time | ncalls | sync_io_time |\n |-----------------------------------------+----------------+----------------+----------+----------------|\n | BEGIN; | 0:00:00.140968 | 0.0% | 414000 | 0:00:00 |\n | INSERT INTO pgbench_history (tid, bid.. | 0:00:03.788899 | 0.0% | 414000 | 0:00:00 |\n | SELECT abalance FROM pgbench_accounts.. | 0:00:04.471754 | 0.0% | 414000 | 0:00:00 |\n | UPDATE pgbench_accounts SET abalance .. | 0:00:21.798029 | 0.2% | 414000 | 0:00:00 |\n | END; | 0:00:00.126220 | 0.0% | 414000 | 0:00:00 |\n | UPDATE pgbench_branches SET bbalance .. | 0:30:00.544749 | 15.9% | 414000 | 0:00:00 |\n | UPDATE pgbench_tellers SET tbalance =.. | 2:38:45.396566 | 83.9% | 414000 | 0:00:00 |\n | BEGIN | 0:00:00.002141 | 0.0% | 212 | 0:00:00 |\n | SELECT pid, application_name AS sourc.. | 0:00:00.039576 | 0.0% | 77 | 0:00:00 |\n | SELECT exists( SELECT ? FROM pg_exten.. | 0:00:00.001085 | 0.0% | 43 | 0:00:00 |\n\n\nBlocking\n********\nDisplay queries holding locks other queries are waiting to be released::\n\n | blocked_pid | blocking_statement | blocking_duration | blocking_pid | blocked_statement | blocked_duration |\n |---------------+-----------------------------------------------------------------------+-------------------------+----------------+----------------------------------------------------------------------|------------------|\n | 1688 | UPDATE pgbench_tellers SET tbalance = tbalance + -2309 WHERE tid = 9; | 0:00:00.018450 | 1724 | UPDATE pgbench_tellers SET tbalance = tbalance + -816 WHERE tid = 9; | 0:00:00.034656 |\n\nOutliers\n********\nShow 10 queries that have longest execution time in aggregate::\n\n | qry | exec_time | prop_exec_time | ncalls | sync_io_time |\n |-----------------------------------------+----------------+----------------+----------+----------------|\n | UPDATE pgbench_tellers SET tbalance =.. | 2:59:30.137916 | 83.9% | 467897 | 0:00:00 |\n | UPDATE pgbench_branches SET bbalance .. | 0:33:53.945889 | 15.8% | 467856 | 0:00:00 |\n | UPDATE pgbench_accounts SET abalance .. | 0:00:25.384166 | 0.2% | 467897 | 0:00:00 |\n | SELECT abalance FROM pgbench_accounts.. | 0:00:05.086917 | 0.0% | 467897 | 0:00:00 |\n | INSERT INTO pgbench_history (tid, bid.. | 0:00:04.356031 | 0.0% | 467848 | 0:00:00 |\n | vacuum pgbench_branches | 0:00:00.336647 | 0.0% | 17 | 0:00:00 |\n | select count(*) from pgbench_accounts ; | 0:00:00.294740 | 0.0% | 1 | 0:00:00 |\n | BEGIN; | 0:00:00.160855 | 0.0% | 467897 | 0:00:00 |\n | END; | 0:00:00.142983 | 0.0% | 467848 | 0:00:00 |\n | SELECT relname, CASE idx_scan WHEN ? .. | 0:00:00.110683 | 0.0% | 6 | 0:00:00 |\n\nVacuum Stats\n************\nShow dead rows and whether an automatic vacuum is expected to be triggered::\n\n | schema | table | last_vacuum | last_autovacuum | rowcount | dead_rowcount | autovacuum_threshold | expect_autovacuum |\n |----------+------------------+------------------+-------------------+------------+-----------------+------------------------+---------------------|\n | public | pgbench_tellers | 2014-04-24 20:02 | 2014-04-24 20:03 | 10 | 0 | 52 | |\n | public | pgbench_branches | 2014-04-24 20:02 | 2014-04-24 20:03 | 1 | 0 | 50 | |\n | public | pgbench_history | 2014-04-23 20:45 | | 15000 | 0 | 3050 | |\n | public | pgbench_accounts | 2014-04-23 20:45 | | 100000 | 17581 | 20050 | |\n\nBloat\n*****\nTable and index bloat in your database ordered by most wasteful::\n\n | type | schemaname | object_name | bloat | waste |\n |--------+--------------+------------------------------------------------+-------+--------------|\n | table | public | pgbench_accounts | 1.3 | 3768 kB |\n | table | public | pgbench_tellers | 19 | 144 kB |\n | table | public | pgbench_branches | 8 | 56 kB |\n\nLong Running Queries\n********************\nShow all queries running longer than five minutes by descending duration::\n\n | pid | duration | query |\n |-------+-----------------+--------------------------------------------------------------------------------------|\n | 19578 | 02:29:11.200129 | EXPLAIN SELECT \"students\".* FROM \"students\" WHERE \"students\".\"id\" = 1450645 LIMIT 1 |\n | 19465 | 02:26:05.542653 | EXPLAIN SELECT \"students\".* FROM \"students\" WHERE \"students\".\"id\" = 1889881 LIMIT 1 |\n | 19632 | 02:24:46.962818 | EXPLAIN SELECT \"students\".* FROM \"students\" WHERE \"students\".\"id\" = 1581884 LIMIT 1 |\n\nSequence Scans\n**************\nShow the count of sequential scans by table descending by order::\n\n | name | count |\n |------------------+---------|\n | pgbench_branches | 57086 |\n | pgbench_tellers | 15595 |\n | pgbench_accounts | 2 |\n | pgbench_history | 0 |\n\nUnused Indexes\n**************\nShow unused and almost unused indexes, ordered by their size relative to the\nnumber of index scans. Exclude indexes of very small tables (less than 5\npages), where the planner will almost invariably select a sequential scan,\nbut may not in the future as the table grows::\n\n | table | index | index_size | index_scans |\n |---------------------+--------------------------------------------+------------+-------------|\n | public.grade_levels | index_placement_attempts_on_grade_level_id | 97 MB | 0 |\n | public.observations | observations_attrs_grade_resources | 33 MB | 0 |\n | public.messages | user_resource_id_idx | 12 MB | 0 |\n\nTotal Table Size\n****************\nShow the size of the tables (including indexes), descending by size::\n\n | name | size |\n |------------------+---------|\n | pgbench_accounts | 18 MB |\n | pgbench_history | 2904 kB |\n | pgbench_tellers | 272 kB |\n | pgbench_branches | 256 kB |\n\nTotal Indexes Size\n******************\nShow the total size of all the indexes on each table, descending by size::\n\n | table | index_size |\n |------------------+--------------|\n | pgbench_accounts | 2208 kB |\n | pgbench_tellers | 16 kB |\n | pgbench_branches | 16 kB |\n | pgbench_history | 0 bytes |\n\nTable Size\n**********\nShow the size of the tables (excluding indexes), descending by size::\n\n | name | size |\n |------------------+---------|\n | pgbench_accounts | 16 MB |\n | pgbench_history | 2904 kB |\n | pgbench_tellers | 256 kB |\n | pgbench_branches | 240 kB |\n\nIndex Size\n**********\nShow the size of indexes, descending by size::\n\n | name | size |\n |-----------------------+---------|\n | pgbench_accounts_pkey | 2208 kB |\n | pgbench_tellers_pkey | 16 kB |\n | pgbench_branches_pkey | 16 kB |\n\nTotal Index Size\n****************\nShow the total size of all indexes::\n\n | size |\n |---------|\n | 2240 kB |\n\nLocks\n*****\nDisplay queries with active locks::\n\n | procpid | relname | transactionid | granted | query_snippet | age\n |---------+---------+---------------+---------+-----------------------+-----------------\n | 31776 | | | t | in transaction | 00:19:29.837898\n | 31776 | | 1294 | t | in transaction | 00:19:29.837898\n | 31912 | | | t | select * from hello; | 00:19:17.94259\n | 3443 | | | t | +| 00:00:00\n | | | | | select +|\n | | | | | pg_stat_activi |\n\nTable Indexes Size\n******************\nShow the total size of all the indexes on each table, descending by size::\n\n | table | index_size |\n |------------------+--------------|\n | pgbench_accounts | 2208 kB |\n | pgbench_tellers | 16 kB |\n | pgbench_branches | 16 kB |\n | pgbench_history | 0 bytes |\n\nPS\n**\nView active queries with execution time::\n\n | pid | source | running_for | waiting | query |\n |-------+----------+-------------------------+-----------+--------------------------------------------------------------------------|\n | 28023 | pgbench | 0:00:00.107013 | 0 | UPDATE pgbench_accounts SET abalance = abalance + 423 WHERE aid = 10736; |\n | 28018 | pgbench | 0:00:00.017257 | 0 | END; |\n | 28015 | pgbench | 0:00:00.001055 | 1 | UPDATE pgbench_branches SET bbalance = bbalance + -4203 WHERE bid = 1; |\n\nVersion\n*******\nGet the Postgres server version::\n\n | version |\n |-----------------------------------------------------------------------------------------------------------------------------------|\n | PostgreSQL 9.3.3 on x86_64-apple-darwin13.0.0, compiled by Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn), 64-bit |\n\n\n\n\nHistory\n-------\n\n0.2.1 (2018-12-01)\n++++++++++++++++++\n* Fixed bug that was truncating index names to only 63 characters\n* Updated various sql statement to match heroku's version (thanks @mantrala)\n\n0.2.0 (2014-05-06)\n++++++++++++++++++\n\n* Added a CLI option. Original idea for this came from `Marek Wywia\u0142\n `_.\n* Remove commas from integer output so no additional parsing is needed if\n someone wants to store the results.\n* Make API more consistent by not raising an exception when the\n \"pg_stat_statement\" module is not installed. Instead a list with a single\n namedtuple containing the error message is returned.\n\n0.1.1 (2014-05-01)\n++++++++++++++++++\n\n* updated documentation\n* increased test coverage\n\n0.1.0 (2014-04-25)\n++++++++++++++++++\n\n* First release on PyPI.\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/scottwoodall/python-pgextras", "keywords": "pgextras", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "pgextras", "package_url": "https://pypi.org/project/pgextras/", "platform": "", "project_url": "https://pypi.org/project/pgextras/", "project_urls": { "Homepage": "https://github.com/scottwoodall/python-pgextras" }, "release_url": "https://pypi.org/project/pgextras/0.2.1/", "requires_dist": null, "requires_python": "", "summary": "Unofficial Python port of Heroku's pgextras that provides various statistics for a Postgres instance.", "version": "0.2.1" }, "last_serial": 4550888, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "5849c925573c8ba9044e1a1caeedb25f", "sha256": "73b4c23abef03e573ff4d486b80e74384929b16d1e75328188c26f89d391a07e" }, "downloads": -1, "filename": "pgextras-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "5849c925573c8ba9044e1a1caeedb25f", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 14259, "upload_time": "2014-04-26T18:51:39", "url": "https://files.pythonhosted.org/packages/d1/f6/49f6fdf1133848e32a192c2a3f39551555ff497130ed4e6146fc68f7793a/pgextras-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "466b72ddb75a7a8314925a8ef0265b91", "sha256": "9ce07e569b520670b61248e32b0e425ba27b9ccd79c26be98a2aaab1683ebeaf" }, "downloads": -1, "filename": "pgextras-0.1.0.tar.gz", "has_sig": false, "md5_digest": "466b72ddb75a7a8314925a8ef0265b91", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12458, "upload_time": "2014-04-26T18:51:32", "url": "https://files.pythonhosted.org/packages/94/4a/dc8db95884396c002ea5b6782e9c161b3ba5f5a073c964c37b130509d7cd/pgextras-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "80e7c91b3553745c1b7709faaeff7ede", "sha256": "7bff7267fef9278f48214da86524f536e620dba46d80b6bc1b2b69850fe4498a" }, "downloads": -1, "filename": "pgextras-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "80e7c91b3553745c1b7709faaeff7ede", "packagetype": "bdist_wheel", "python_version": "3.3", "requires_python": null, "size": 15075, "upload_time": "2014-05-01T18:59:01", "url": "https://files.pythonhosted.org/packages/f1/d8/b51f8dc4c9c4990647c4bfcd84b134f592334cf25fbe37a771101b170e21/pgextras-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b62074673e0d2ed47cfd21509fa6e49f", "sha256": "55078739d7810163873a04d987c554759bbd92d3e8c2be6dc03d64cab66e4da1" }, "downloads": -1, "filename": "pgextras-0.1.1.tar.gz", "has_sig": false, "md5_digest": "b62074673e0d2ed47cfd21509fa6e49f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13178, "upload_time": "2014-05-01T18:58:15", "url": "https://files.pythonhosted.org/packages/22/65/b47ef725dcb8e67a9b726fbf9b982f2e39a32afa5656dfe5a786d5b1f921/pgextras-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "b7b940c56f3a731e9d5b79177f88f058", "sha256": "df0ff0ba10c772d5c8bd68cad59c22ff76990c1abb7011f979af9160ed319581" }, "downloads": -1, "filename": "pgextras-0.2.0.tar.gz", "has_sig": false, "md5_digest": "b7b940c56f3a731e9d5b79177f88f058", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14572, "upload_time": "2014-05-06T19:37:12", "url": "https://files.pythonhosted.org/packages/2b/0b/bc6f552f3dc334903708355581519163b74fdd52a8f44fed828a9e552710/pgextras-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "d597edac70635337ef9b852ac274c182", "sha256": "b1d6ad30404010df0e748cf363d793bf10e0d95e12071841e0c387487afad0a1" }, "downloads": -1, "filename": "pgextras-0.2.1.tar.gz", "has_sig": false, "md5_digest": "d597edac70635337ef9b852ac274c182", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18360, "upload_time": "2018-12-01T20:32:40", "url": "https://files.pythonhosted.org/packages/2c/5e/8638e03acfbbce9f65bca3e9648af32a33e962d89a538a0503a08c9ac449/pgextras-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d597edac70635337ef9b852ac274c182", "sha256": "b1d6ad30404010df0e748cf363d793bf10e0d95e12071841e0c387487afad0a1" }, "downloads": -1, "filename": "pgextras-0.2.1.tar.gz", "has_sig": false, "md5_digest": "d597edac70635337ef9b852ac274c182", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18360, "upload_time": "2018-12-01T20:32:40", "url": "https://files.pythonhosted.org/packages/2c/5e/8638e03acfbbce9f65bca3e9648af32a33e962d89a538a0503a08c9ac449/pgextras-0.2.1.tar.gz" } ] }