<?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>Helion-Prime Solutions blog &#187; rdbms</title>
	<atom:link href="http://blogs.helion-prime.com/category/rdbms/feed" rel="self" type="application/rss+xml" />
	<link>http://blogs.helion-prime.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Mon, 10 May 2010 17:51:32 +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>Tuning of Postgresql under OpenBSD</title>
		<link>http://blogs.helion-prime.com/2010/02/25/tuning-of-postgresql-under-openbsd.html</link>
		<comments>http://blogs.helion-prime.com/2010/02/25/tuning-of-postgresql-under-openbsd.html#comments</comments>
		<pubDate>Thu, 25 Feb 2010 15:04:00 +0000</pubDate>
		<dc:creator>alex.shapovalov</dc:creator>
				<category><![CDATA[openBSD]]></category>
		<category><![CDATA[rdbms]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[RoR]]></category>

		<guid isPermaLink="false">http://blogs.helion-prime.com/?p=664</guid>
		<description><![CDATA[Preamble
I assume that you already made your best with help of your favorite programming language
and recommended postgresql performance tips: http://www.postgresql.org/docs/8.4/static/performance-tips.html
Postgresql resources
No doubt that standard postgresql configuration is far from modern production environments.
Therefore you need to spend enough time with following sources.
1. resource consumption documentation:
http://www.postgresql.org/docs/8.4/static/runtime-config-resource.html
The most important parameters are:
work_mem (integer)
shared_buffers (integer)
2. Query Planning documentation:
http://www.postgresql.org/docs/current/static/runtime-config-query.html
The most important [...]]]></description>
			<content:encoded><![CDATA[<h2>Preamble</h2>
<p>I assume that you already made your best with help of your favorite programming language<br />
and recommended postgresql performance tips: <a href="http://www.postgresql.org/docs/8.4/static/performance-tips.html">http://www.postgresql.org/docs/8.4/static/performance-tips.html</a></p>
<h2>Postgresql resources</h2>
<p>No doubt that standard postgresql configuration is far from modern production environments.<br />
Therefore you need to spend enough time with following sources.</p>
<p><strong>1. resource consumption documentation:</strong><br />
<a href="http://www.postgresql.org/docs/8.4/static/runtime-config-resource.html">http://www.postgresql.org/docs/8.4/static/runtime-config-resource.html</a></p>
<p>The most important parameters are:<br />
work_mem (integer)<br />
shared_buffers (integer)</p>
<p><strong>2. Query Planning documentation:</strong><br />
<a href="http://www.postgresql.org/docs/current/static/runtime-config-query.html">http://www.postgresql.org/docs/current/static/runtime-config-query.html</a></p>
<p>The most important parameters are:<br />
effective_cache_size (integer)<br />
random_page_cost (floating point)</p>
<h2>OpenBSD resources</h2>
<p>The default sizes in the GENERIC kernel are insignificant also and waiting for your tuning as well.<br />
Posgtresql doesn&#8217;t start without enough memory size so always know when you need to increase kern.shminfo.shmmax.</p>
<p><strong>Setting that we can change in /etc/sysctl.conf</strong><br />
the maximum number of System V IPC system-wide semaphore sets (and identifiers) which can exist at any given time:<br />
kern.seminfo.semmni</p>
<p>the maximum total individual System V IPC semaphores which can be assigned by applications:<br />
kern.seminfo.semmns</p>
<p>the amount of shared memory available in the system (bytes):<br />
kern.shminfo.shmmax</p>
<p>the maximum number of shared memory segments:<br />
sysctl kern.shminfo.shmseg</p>
<p>Full list of setting you can see with:<br />
# man sysctl</p>
<p><strong>OpenBSD kernel parameters</strong><br />
So, there are set of parameters that can be tuned only with kernel rebuild. </p>
<p>You should tune them only if system works unstable with default values and you have:<br />
kernel warnings: “uvm_mapent_alloc: out of static map entries”<br />
or panics like:  “panic: malloc: out of space in kmem_map”</p>
<p>NKMEMPAGES<br />
This option defines number of pages in kernel kmem_map structure.</p>
<p>MAX_KMAPENT<br />
It defines number of static entries in kernel kmem_map (kernel virtual memory).</p>
<p>They can be changed in:<br />
/usr/src/sys/arch/conf/GENERIC</p>
<p>As start you need to recheck  &#8216;Building the System from Source&#8217; part of OpenBSD documentation:<br />
<a href="http://openbsd.org/faq/faq5.htm">http://openbsd.org/faq/faq5.htm</a></p>
<p>Usually administrators select these parameters using set of tests on dedicated testing box where<br />
 they emulate load of  production servers.</p>
<h2>Example</h2>
<p>our test server: 1x Intel Quad core CPU, 2GB RAM<br />
software: Ruby on Rails application, postgresql DB, memcached.<br />
load: about 15.000 users/day, peak load: 10 users/sec.</p>
<p>postgresql_dir/data/postgresql.conf</p>
<div class="codecolorer-container bash mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;"># RESOURCE USAGE</span><br />
shared_buffers = 738MB<br />
max_prepared_transactions = <span style="color: #000000;">30</span><br />
work_mem = 16MB<br />
max_fsm_pages = <span style="color: #000000;">2000000</span><br />
<br />
<span style="color: #666666; font-style: italic;"># QUERY TUNING</span><br />
effective_cache_size = 512MB<br />
random_page_cost = <span style="color: #000000;">1.7</span></div></td></tr></tbody></table></div>
<p>/etc/sysctl.conf</p>
<div class="codecolorer-container bash mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">kern.seminfo.semmni = <span style="color: #000000;">256</span><br />
kern.seminfo.semmns = <span style="color: #000000;">2048</span><br />
kern.shminfo.shmmax = <span style="color: #000000;">805306368</span> &nbsp; &nbsp;<span style="color: #666666; font-style: italic;"># Shared memory segment size is 768M</span></div></td></tr></tbody></table></div>
<p>/usr/src/sys/arch/conf/GENERIC</p>
<div class="codecolorer-container bash mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">## custom settings</span><br />
option MAX_KMAPENT = <span style="color: #000000;">3072</span><br />
option NKMEMPAGES = <span style="color: #000000;">32768</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://blogs.helion-prime.com/2010/02/25/tuning-of-postgresql-under-openbsd.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
