<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://kb.owrench.com/index.php?action=history&amp;feed=atom&amp;title=Postgresql_slow_query</id>
	<title>Postgresql slow query - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://kb.owrench.com/index.php?action=history&amp;feed=atom&amp;title=Postgresql_slow_query"/>
	<link rel="alternate" type="text/html" href="http://kb.owrench.com/index.php?title=Postgresql_slow_query&amp;action=history"/>
	<updated>2026-05-04T04:22:41Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>http://kb.owrench.com/index.php?title=Postgresql_slow_query&amp;diff=159&amp;oldid=prev</id>
		<title>137.97.105.157: Postgresql slow query</title>
		<link rel="alternate" type="text/html" href="http://kb.owrench.com/index.php?title=Postgresql_slow_query&amp;diff=159&amp;oldid=prev"/>
		<updated>2021-04-27T05:32:42Z</updated>

		<summary type="html">&lt;p&gt;Postgresql slow query&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:It-support|Postgresql slow query]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1) To enable slow query log in postgresql, firstly you have to open the postgres configuration file &amp;quot;/etc/postgresql/9.1/main/postgresql.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
2) Then find the following line &lt;br /&gt;
&lt;br /&gt;
#log_min_duration_statement = -1&lt;br /&gt;
&lt;br /&gt;
Uncomment it and replace -1 with a query runtime threshold in milliseconds.&lt;br /&gt;
&lt;br /&gt;
eg: log_min_duration_statement = 1000&lt;br /&gt;
&lt;br /&gt;
3) Make sure logging_collector is set to on.&lt;br /&gt;
&lt;br /&gt;
4) Then save the configuration and restart the service&lt;br /&gt;
&lt;br /&gt;
sudo systemctl restart postgresql&lt;br /&gt;
&lt;br /&gt;
5) The go to the postgreSQL log collecting directory &amp;quot;/var/lib/pgsql/data/pg_log/&amp;quot; and find the log file in it.&lt;/div&gt;</summary>
		<author><name>137.97.105.157</name></author>
		
	</entry>
</feed>