<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Lazy Sys Admin&#187; Performance Tuning</title>
	<atom:link href="http://www.thelazysysadmin.net/tag/performance-tuning/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thelazysysadmin.net</link>
	<description>Why do things the hard way?</description>
	<lastBuildDate>Mon, 07 Jun 2010 22:24:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PgFouine Automatic Report Setup with PostgreSQL &amp; Logrotate</title>
		<link>http://www.thelazysysadmin.net/2009/08/pgfouine-automatic-report-setup-with-postgresql-logrotate/</link>
		<comments>http://www.thelazysysadmin.net/2009/08/pgfouine-automatic-report-setup-with-postgresql-logrotate/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 04:49:06 +0000</pubDate>
		<dc:creator>Jon Smith</dc:creator>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Sys Admin]]></category>
		<category><![CDATA[Logrotate]]></category>
		<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[PgFouine]]></category>
		<category><![CDATA[Syslog]]></category>

		<guid isPermaLink="false">http://www.thelazysysadmin.net/?p=605</guid>
		<description><![CDATA[Monitoring &#38; analysing your PostgreSQL server logs with PgFouine provides you with a way to see which queries are performing badly and need optimisation. It can also provide insight into busy periods and give some basic query stats such as the number of INSERT, DELETE, UPDATE, and SELECT operations.
Requirements

PgFouine
php
Logrotate
PostgreSQL setup to log to syslog (Tested [...]]]></description>
			<content:encoded><![CDATA[<p>Monitoring &amp; analysing your PostgreSQL server logs with PgFouine provides you with a way to see which queries are performing badly and need optimisation. It can also provide insight into busy periods and give some basic query stats such as the number of INSERT, DELETE, UPDATE, and SELECT operations.</p>
<p><span id="more-605"></span><strong>Requirements</strong></p>
<ul>
<li><a title="PgFouine" href="http://pgfouine.projects.postgresql.org/" target="_blank">PgFouine</a></li>
<li>php</li>
<li>Logrotate</li>
<li>PostgreSQL setup to log to syslog (Tested with PostgreSQL 8.3 but should work with earlier versions)</li>
</ul>
<p><strong>PostgreSQL Setup</strong></p>
<p>First you need to setup PostgreSQL to log to syslog. Set the following in your postgresql.conf</p>
<pre class="brush: plain;">log_destination = 'syslog'

# Ensure that the following lines are REMMED out
#
# logging_collector
# log_directory
# log_filename
# log_truncate_on_rotation</pre>
<p>You may set the &#8220;syslog_facility&#8221; and &#8220;syslog_ident&#8221; options if you wish, but i handle these items in the syslog-ng.conf file.</p>
<p>You will also need to tell Postgres what to log</p>
<pre class="brush: plain;">client_min_messages = notice            # values in order of decreasing detail:
                                        #   debug5
                                        #   debug4
                                        #   debug3
                                        #   debug2
                                        #   debug1
                                        #   log
                                        #   notice
                                        #   warning
                                        #   error

log_min_messages = notice               # values in order of decreasing detail:
                                        #   debug5
                                        #   debug4
                                        #   debug3
                                        #   debug2
                                        #   debug1
                                        #   info
                                        #   notice
                                        #   warning
                                        #   error
                                        #   log
                                        #   fatal
                                        #   panic

log_error_verbosity = default           # terse, default, or verbose messages

log_min_error_statement = debug2        # values in order of decreasing detail:
                                        #   debug5
                                        #   debug4
                                        #   debug3
                                        #   debug2
                                        #   debug1
                                        #   info
                                        #   notice
                                        #   warning
                                        #   error
                                        #   log
                                        #   fatal
                                        #   panic (effectively off)

log_min_duration_statement = 200        # -1 is disabled, 0 logs all statements
                                        # and their durations, &amp;gt; 0 logs only
                                        # statements running at least this time.
log_line_prefix = '%t %d %u %h '</pre>
<p>I have a fairly busy DB server so I am only interested in queries that take longer then 200ms. You will need to set this value to suit your needs, set it to low and you will produce many log lines, set it to high and you wont produce anything.</p>
<p><strong>Syslog Setup</strong></p>
<p>Next you need to setup syslog to log PostgreSQL to a different file (the following instruction will work for Syslog-ng on an OpenSUSE box, your milage may vary).</p>
<p>Setup a filter:</p>
<pre class="brush: plain;">filter f_postgres   { match('^postgres'); };</pre>
<p>And a Destination:</p>
<pre class="brush: plain;"># PostgreSQL messages
destination postgres { file(&quot;/var/log/pgsql/postgresql.log&quot;); };
log { source(src); filter(f_postgres); destination(postgres); flags(final); };</pre>
<p><strong>Scripts</strong></p>
<p>Create the following as a script for bash. Ensure you setup the execute bit on the file ie &#8220;chmod +x pgfouine_process&#8221;.</p>
<pre class="brush: plain;">#!/bin/bash

PGFOUINE=&quot;/srv/www/htdocs/pgfouine/pgfouine.php&quot;
DATESTAMP=$(date +%G%m%d)
YEAR=$(date +%G)
MONTH=$(date +%m)
REPORTDIR=&quot;/srv/www/htdocs/reports&quot;
PGSQLLOG=&quot;/var/log/pgsql/postgresql.log&quot;

mkdir $REPORTDIR/$YEAR/$MONTH -p

php $PGFOUINE -file $PGSQLLOG &amp;gt; $REPORTDIR/$YEAR/$MONTH/$DATESTAMP.htm</pre>
<p>You may customise this script to suit your needs depending on where you put the PgFouine files and where you want to store/serve your reports from. You may also with to send the report via email once it is generated, the sky is the limit (ok, sorry for the cliche).</p>
<p><strong>Logrotate</strong></p>
<p>To execute this script each time the log file is rotated put the following file into your /etc/logrotate.d directory.</p>
<pre class="brush: plain;">/var/log/pgsql/postgresql.log {
    compress
    dateext
    rotate 99
    daily
    notifempty
    missingok
    create 640 postgres users
    copytruncate
    prerotate
        /var/lib/pgsql/bin/pgfouine_process
    endscript
}</pre>
<p>The important thing for this is the prerotate section. This will run the script first before rotating the log file.</p>
<p>If you don&#8217;t have Logrotate setup you could easily run the pgfouine script on a daily basis with Cron.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thelazysysadmin.net/2009/08/pgfouine-automatic-report-setup-with-postgresql-logrotate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PostgreSQL Performance Tuning</title>
		<link>http://www.thelazysysadmin.net/2009/06/postgresql-performance-tuning/</link>
		<comments>http://www.thelazysysadmin.net/2009/06/postgresql-performance-tuning/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 01:33:42 +0000</pubDate>
		<dc:creator>Jon Smith</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[Performance Tuning]]></category>

		<guid isPermaLink="false">http://www.thelazysysadmin.net/?p=434</guid>
		<description><![CDATA[I have had my head buried in Postgres tuning parameters today. There is so many different options to look at and no real definitive guidelines out there, and to make matters worse you can really impede performance with incorrect tuning parameters which is probably counter productive if your interested in tuning for performance :-).]]></description>
			<content:encoded><![CDATA[<p>Well I have had my head buried in Postgres tuning parameters today. There are so many different options to look at and no real definitive guidelines out there, and to make matters worse you can really impede performance with incorrect tuning parameters which is probably counter productive if your interested in tuning for performance <img src='http://www.thelazysysadmin.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
<p>I have read a lot of blog posts and articles today and will list the ones I found most helpful below.</p>
<p><span id="more-434"></span>There is a lot of information out there that is now mostly out of date. PostgreSQL 8.3 changed the game when it came  performance tuning and a lot of the hard and fast rules that had been true for many years are now no longer true. So my one piece of advise when it comes to looking at the information out there, make sure it is relevant to the version of Postgres you are using.</p>
<p>The other thing to keep in mind are there are certain performance parameters that can improve performance, yet reduce reliability or time to restore objectives for your database and also the inverse of this decreased performance and increased reliability. You need to decide what your individual requirements are, it is mostly a counter balance between Performance and Reliability (reliability being anything from producing instability in the disk system by changing caching methods, through to the amount of data lost at power failure, or if using WAL log archiving how long between log writes and how often to write checkpoints). As always when changing any value that is suggested do your own research. For me I looked at the official Postgres documentation as well as just googling the setting name (ie shared_buffers) and reading information from the mail list archives and other tutorials.</p>
<p>Resources I used:</p>
<ul>
<li><a href="http://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server" target="_blank">http://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server</a></li>
<li><a href="http://blog.gtuhl.com/2009/03/08/postgresql-setup-basics/" target="_blank">http://blog.gtuhl.com/2009/03/08/postgresql-setup-basics/</a></li>
<li><a href="http://blog.gtuhl.com/2009/05/13/dell-md1120-perc6e-performance/" target="_blank">http://blog.gtuhl.com/2009/05/13/dell-md1120-perc6e-performance/</a></li>
<li><a href="http://www.postgresql.org/docs/8.3/static/" target="_blank">http://www.postgresql.org/docs/8.3/static/</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.thelazysysadmin.net/2009/06/postgresql-performance-tuning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
