{"id":16063,"date":"2020-07-21T07:53:15","date_gmt":"2020-07-21T07:53:15","guid":{"rendered":"https:\/\/dbtut.com\/?p=16063"},"modified":"2020-07-21T07:54:54","modified_gmt":"2020-07-21T07:54:54","slug":"how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements","status":"publish","type":"post","link":"https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/","title":{"rendered":"How To Find Long Running Queries in Postgresql using pg_stat_statements"},"content":{"rendered":"<p>In order to find long running queries in PostgreSQL, we can set the log_min_duration_statement parameter in the postgresql.conf file to a certain threshold value and ensure that the queries that is longer than this threshold are written to the log file. This configuration helps us find long running queries. We cannot see queries that take less than the threshold we have specified.<\/p>\n<p>The pg_stat_statements extension records statistics for all SQL queries running in the database. It is one of the most important extensions that can be used to detect performance problems. It allows us to obtain information such as total elapsed time, number of rows, execution count for each query run in the database where it is created.<\/p>\n<h3>How To Install pg_stat_statements\u00a0 Extension<\/h3>\n<p>We install the contrib package in the version of our current PostgreSQL Cluster:<\/p>\n<p>For CentOS \/ Redhat distributions:<\/p>\n<pre class=\"lang:default decode:true \">sudo yum install postgresql12-contrib<\/pre>\n<p>For Debian based distributions:<\/p>\n<pre class=\"lang:default decode:true \">sudo apt-get install postgresql-contrib-12<\/pre>\n<p>We edit the shared_preload_libraries parameter in the postgresql.conf file to include the pg_stat_statements module as follows:<\/p>\n<pre class=\"lang:default decode:true\">vim \/var\/lib\/pgsql\/12\/data\/postgresql.conf\n&gt;\nshared_preload_libraries = 'pg_stat_statements'<\/pre>\n<p>Or, we can set it using the ALTER SYSTEM SET command by connecting to PostgreSQL as follows:<\/p>\n<pre class=\"lang:default decode:true \">ALTER SYSTEM SET shared_preload_libraries TO 'pg_stat_statements';<\/pre>\n<p>In order for the change in shared_preload_libraries parameter to take effect, the PostgreSQL service must be restarted, we restart the service as follows:<\/p>\n<p>For CentOS \/ Redhat distributions:<\/p>\n<pre class=\"lang:default decode:true \">sudo systemctl restart postgresql-12<\/pre>\n<p>For Debian based distributions:<\/p>\n<pre class=\"lang:default decode:true \">sudo systemctl restart postgresql@main-12<\/pre>\n<p>We connect to the database where we want to monitor the query statistics with a user with superuser rights and create the extension:<\/p>\n<pre class=\"lang:default decode:true \">CREATE EXTENSION pg_stat_statements;<\/pre>\n<p>We can display the pg_stat_statements extension we created with <code>\\dx<\/code> as follows:<\/p>\n<p id=\"BdTyJAI\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-16064  aligncenter\" src=\"https:\/\/dbtut.com\/wp-content\/uploads\/2020\/07\/img_5f169bd3bb0b1.png\" alt=\"\" width=\"842\" height=\"293\" \/><\/p>\n<p>We can see the query with the highest average runtime in the database as follows:<\/p>\n<pre class=\"lang:default decode:true \">SELECT total_time, min_time, max_time, mean_time, calls, rows, query\nFROM pg_stat_statements\nORDER BY mean_time DESC\nLIMIT 1;<\/pre>\n<p>Example command output is as follows:<\/p>\n<p id=\"qEtxwRB\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-16065  aligncenter\" src=\"https:\/\/dbtut.com\/wp-content\/uploads\/2020\/07\/img_5f169c104ae84.png\" alt=\"\" width=\"816\" height=\"425\" \/><\/p>\n<p><strong>total_time in pg_stat_statements:<\/strong> Returns the total runtime of the query in milliseconds.<\/p>\n<p><strong>min_time &amp; max_time in pg_stat_statements:<\/strong> Returns the minimum and maximum runtimes of the query.<\/p>\n<p><strong>mean_time in pg_stat_statements:<\/strong> Returns the average run time of the query in milliseconds with total_time \/ calls.<\/p>\n<p><strong>calls in pg_stat_statements:<\/strong> Returns the total number of times the query was run.<\/p>\n<p><strong>rows in pg_stat_statements:<\/strong> Returns the total number of rows returned or affected as a result of the query.<\/p>\n<p><strong>query in pg_stat_statements:<\/strong> Returns the running query. By default, up to 1024 bytes of the query are displayed. You can change this value with the track_activity_query_size parameter.<\/p>\n<h3>Change pg_stat_statements max query count:<\/h3>\n<p>By default, the pg_stat_statements extension stores statistics for the first 5,000 queries it encounters. We can change this number by editing the parameter <strong>pg_stat_statements.max<\/strong>. The PostgreSQL service must be restarted for the change in the parameter to take effect.<\/p>\n<p>As an example, we can set it to 10000 as follows:<\/p>\n<pre class=\"lang:default decode:true\">ALTER SYSTEM SET pg_stat_statements.max TO 10000;<\/pre>\n<h3>Reset pg_stat_statements Statistics:<\/h3>\n<p>Statistics obtained by pg_stat_statements accumulate until reset.<\/p>\n<p>You can run the following function by connecting to the database with a user with superuser rights to reset the statistics data:<\/p>\n<pre class=\"lang:default decode:true \">SELECT pg_stat_statements_reset();<\/pre>\n<p>In this article I mainly mentioned the use of pg_stat_statements. For more detailed information, you can look at below link;<\/p>\n<p>https:\/\/www.postgresql.org\/docs\/12\/pgstatstatements.html<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_16063\" class=\"pvc_stats all  \" data-element-id=\"16063\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/dbtut.com\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In order to find long running queries in PostgreSQL, we can set the log_min_duration_statement parameter in the postgresql.conf file to a certain threshold value and ensure that the queries that is longer than this threshold are written to the log file. This configuration helps us find long running queries. We cannot see queries that take &hellip;<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_16063\" class=\"pvc_stats all  \" data-element-id=\"16063\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/dbtut.com\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":477,"featured_media":16067,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[5],"tags":[9800,9803,9789,9795,9797,9790,9792,9791,9794,9788,9799,9801,9796,9793,9798],"class_list":["post-16063","post","type-post","status-publish","format-standard","has-post-thumbnail","","category-postgres","tag-calls-in-pg_stat_statements","tag-change-pg_stat_statements-max-query-count","tag-how-to-install-pg_stat_statements-extension","tag-mean_time-in-pg_stat_statements","tag-min_time-max_time-in-pg_stat_statements","tag-pg_stat_statements-must-be-loaded-via-shared_preload_libraries","tag-pg_stat_statements-postgresql","tag-pg_stat_statements-postgresql-12","tag-pg_stat_statements-max","tag-postgresql-pg_stat_statements-install","tag-query-in-pg_stat_statements","tag-reset-pg_stat_statements-statistics","tag-rows-in-pg_stat_statements","tag-shared_preload_libraries","tag-total_time-in-pg_stat_statements"],"aioseo_notices":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How To Find Long Running Queries in Postgresql using pg_stat_statements - Database Tutorials<\/title>\n<meta name=\"description\" content=\"How To Find Long Running Queries in Postgresql using pg_stat_statements\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Find Long Running Queries in Postgresql using pg_stat_statements - Database Tutorials\" \/>\n<meta property=\"og:description\" content=\"How To Find Long Running Queries in Postgresql using pg_stat_statements\" \/>\n<meta property=\"og:url\" content=\"https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/\" \/>\n<meta property=\"og:site_name\" content=\"Database Tutorials\" \/>\n<meta property=\"article:published_time\" content=\"2020-07-21T07:53:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-07-21T07:54:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/dbtut.com\/wp-content\/uploads\/2020\/07\/Ads\u0131z-5.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"475\" \/>\n\t<meta property=\"og:image:height\" content=\"277\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Zekiye AYDEM\u0130R\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Zekiye AYDEM\u0130R\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/\"},\"author\":{\"name\":\"Zekiye AYDEM\u0130R\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/44676b832bdd5cfa774e985b6d85cd3b\"},\"headline\":\"How To Find Long Running Queries in Postgresql using pg_stat_statements\",\"datePublished\":\"2020-07-21T07:53:15+00:00\",\"dateModified\":\"2020-07-21T07:54:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/\"},\"wordCount\":536,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/dbtut.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2020\/07\/Ads\u0131z-5.jpg\",\"keywords\":[\"calls in pg_stat_statements\",\"Change pg_stat_statements max query count:\",\"How To Install pg_stat_statements\u00a0 Extension\",\"mean_time in pg_stat_statements\",\"min_time &amp; max_time in pg_stat_statements\",\"Pg_stat_statements must be loaded via shared_preload_libraries\",\"Pg_stat_statements PostgreSQL\",\"Pg_stat_statements PostgreSQL 12\",\"pg_stat_statements.max\",\"PostgreSQL pg_stat_statements install\",\"query in pg_stat_statements\",\"Reset pg_stat_statements Statistics\",\"rows in pg_stat_statements\",\"shared_preload_libraries\",\"total_time in pg_stat_statements\"],\"articleSection\":[\"PostgreSQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/\",\"url\":\"https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/\",\"name\":\"How To Find Long Running Queries in Postgresql using pg_stat_statements - Database Tutorials\",\"isPartOf\":{\"@id\":\"https:\/\/dbtut.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2020\/07\/Ads\u0131z-5.jpg\",\"datePublished\":\"2020-07-21T07:53:15+00:00\",\"dateModified\":\"2020-07-21T07:54:54+00:00\",\"description\":\"How To Find Long Running Queries in Postgresql using pg_stat_statements\",\"breadcrumb\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/#primaryimage\",\"url\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2020\/07\/Ads\u0131z-5.jpg\",\"contentUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2020\/07\/Ads\u0131z-5.jpg\",\"width\":475,\"height\":277},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/dbtut.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How To Find Long Running Queries in Postgresql using pg_stat_statements\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/dbtut.com\/#website\",\"url\":\"https:\/\/dbtut.com\/\",\"name\":\"Database Tutorials\",\"description\":\"MSSQL, Oracle, PostgreSQL, MySQL, MariaDB, DB2, Sybase, Teradata, Big Data, NOSQL, MongoDB, Couchbase, Cassandra, Windows, Linux\",\"publisher\":{\"@id\":\"https:\/\/dbtut.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/dbtut.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/dbtut.com\/#organization\",\"name\":\"dbtut\",\"url\":\"https:\/\/dbtut.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg\",\"contentUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg\",\"width\":223,\"height\":36,\"caption\":\"dbtut\"},\"image\":{\"@id\":\"https:\/\/dbtut.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/44676b832bdd5cfa774e985b6d85cd3b\",\"name\":\"Zekiye AYDEM\u0130R\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/eac70389d03a5a61b22bd277efdc0bae561e8ee31279a0c187c57f9b16e15620?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/eac70389d03a5a61b22bd277efdc0bae561e8ee31279a0c187c57f9b16e15620?s=96&d=mm&r=g\",\"caption\":\"Zekiye AYDEM\u0130R\"},\"url\":\"https:\/\/dbtut.com\/index.php\/author\/zekiyeaydemir\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How To Find Long Running Queries in Postgresql using pg_stat_statements - Database Tutorials","description":"How To Find Long Running Queries in Postgresql using pg_stat_statements","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/","og_locale":"en_US","og_type":"article","og_title":"How To Find Long Running Queries in Postgresql using pg_stat_statements - Database Tutorials","og_description":"How To Find Long Running Queries in Postgresql using pg_stat_statements","og_url":"https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/","og_site_name":"Database Tutorials","article_published_time":"2020-07-21T07:53:15+00:00","article_modified_time":"2020-07-21T07:54:54+00:00","og_image":[{"width":475,"height":277,"url":"https:\/\/dbtut.com\/wp-content\/uploads\/2020\/07\/Ads\u0131z-5.jpg","type":"image\/jpeg"}],"author":"Zekiye AYDEM\u0130R","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Zekiye AYDEM\u0130R","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/#article","isPartOf":{"@id":"https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/"},"author":{"name":"Zekiye AYDEM\u0130R","@id":"https:\/\/dbtut.com\/#\/schema\/person\/44676b832bdd5cfa774e985b6d85cd3b"},"headline":"How To Find Long Running Queries in Postgresql using pg_stat_statements","datePublished":"2020-07-21T07:53:15+00:00","dateModified":"2020-07-21T07:54:54+00:00","mainEntityOfPage":{"@id":"https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/"},"wordCount":536,"commentCount":2,"publisher":{"@id":"https:\/\/dbtut.com\/#organization"},"image":{"@id":"https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/#primaryimage"},"thumbnailUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2020\/07\/Ads\u0131z-5.jpg","keywords":["calls in pg_stat_statements","Change pg_stat_statements max query count:","How To Install pg_stat_statements\u00a0 Extension","mean_time in pg_stat_statements","min_time &amp; max_time in pg_stat_statements","Pg_stat_statements must be loaded via shared_preload_libraries","Pg_stat_statements PostgreSQL","Pg_stat_statements PostgreSQL 12","pg_stat_statements.max","PostgreSQL pg_stat_statements install","query in pg_stat_statements","Reset pg_stat_statements Statistics","rows in pg_stat_statements","shared_preload_libraries","total_time in pg_stat_statements"],"articleSection":["PostgreSQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/","url":"https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/","name":"How To Find Long Running Queries in Postgresql using pg_stat_statements - Database Tutorials","isPartOf":{"@id":"https:\/\/dbtut.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/#primaryimage"},"image":{"@id":"https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/#primaryimage"},"thumbnailUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2020\/07\/Ads\u0131z-5.jpg","datePublished":"2020-07-21T07:53:15+00:00","dateModified":"2020-07-21T07:54:54+00:00","description":"How To Find Long Running Queries in Postgresql using pg_stat_statements","breadcrumb":{"@id":"https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/#primaryimage","url":"https:\/\/dbtut.com\/wp-content\/uploads\/2020\/07\/Ads\u0131z-5.jpg","contentUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2020\/07\/Ads\u0131z-5.jpg","width":475,"height":277},{"@type":"BreadcrumbList","@id":"https:\/\/dbtut.com\/index.php\/2020\/07\/21\/how-to-find-long-running-queries-in-postgresql-using-pg_stat_statements\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/dbtut.com\/"},{"@type":"ListItem","position":2,"name":"How To Find Long Running Queries in Postgresql using pg_stat_statements"}]},{"@type":"WebSite","@id":"https:\/\/dbtut.com\/#website","url":"https:\/\/dbtut.com\/","name":"Database Tutorials","description":"MSSQL, Oracle, PostgreSQL, MySQL, MariaDB, DB2, Sybase, Teradata, Big Data, NOSQL, MongoDB, Couchbase, Cassandra, Windows, Linux","publisher":{"@id":"https:\/\/dbtut.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/dbtut.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/dbtut.com\/#organization","name":"dbtut","url":"https:\/\/dbtut.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/#\/schema\/logo\/image\/","url":"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg","contentUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg","width":223,"height":36,"caption":"dbtut"},"image":{"@id":"https:\/\/dbtut.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/dbtut.com\/#\/schema\/person\/44676b832bdd5cfa774e985b6d85cd3b","name":"Zekiye AYDEM\u0130R","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/eac70389d03a5a61b22bd277efdc0bae561e8ee31279a0c187c57f9b16e15620?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/eac70389d03a5a61b22bd277efdc0bae561e8ee31279a0c187c57f9b16e15620?s=96&d=mm&r=g","caption":"Zekiye AYDEM\u0130R"},"url":"https:\/\/dbtut.com\/index.php\/author\/zekiyeaydemir\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts\/16063","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/users\/477"}],"replies":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/comments?post=16063"}],"version-history":[{"count":0,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts\/16063\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/media\/16067"}],"wp:attachment":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/media?parent=16063"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/categories?post=16063"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/tags?post=16063"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}