<?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>Postgres performance tuning &#8211; Harry Jackson</title>
	<atom:link href="http://127.0.0.1:8090/tag/postgres-performance-tuning/feed" rel="self" type="application/rss+xml" />
	<link>http://127.0.0.1:8090</link>
	<description>Parent, Painter, Programmer</description>
	<lastBuildDate>Mon, 21 Nov 2005 06:59:56 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1</generator>
	<item>
		<title>Tuning Postgres</title>
		<link>http://127.0.0.1:8090/tuning_postgres.htm</link>
					<comments>http://127.0.0.1:8090/tuning_postgres.htm#respond</comments>
		
		<dc:creator><![CDATA[harry]]></dc:creator>
		<pubDate>Mon, 21 Nov 2005 06:59:56 +0000</pubDate>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[Postgres performance tuning]]></category>
		<guid isPermaLink="false">http://www.hjackson.org/wp/?p=297</guid>

					<description><![CDATA[The following is was what I noticed when comparing particular postgresql configuration parameters for an application I currently use. This is for a particular select query which is heavily used. It is being run against a 3 column 10 million row table with a non unique index on one of the int4 columns. The query &#8230; <p class="link-more"><a href="http://127.0.0.1:8090/tuning_postgres.htm" class="more-link">Continue reading<span class="screen-reader-text"> "Tuning Postgres"</span></a></p>]]></description>
										<content:encoded><![CDATA[<p>The following is was what I noticed when comparing particular postgresql configuration parameters for an application I currently use.<br />
This is for a particular select query which is heavily used. It is being run against a 3 column 10 million row table with a non unique index on one of the int4 columns. The query returns (123910 rows). All times are averages of several attempts at running the query and no other activity except that to run the OS was taking place at the time. Where the best and worst times differ by a noticeable amount I have added a second line to the row.<br />
shared_buffers  effective_cache<br />
1024            200             Time: 843.300 ms<br />
8192            200             Time: 793.345 ms<br />
16384           200             Time: 813.399 ms<br />
32768           200             Time: 360.111 ms   Time: 401.952 ms<br />
65536           200             Time: 379.023 ms   Time: 439.706 ms<br />
131072          200             Time: 387.866 ms   Time: 404.930 ms<br />
262144          200             Time: 362.229 ms   Time: 384.344 ms<br />
327680          200             Time: 359.975 ms   Time: 383.517 ms<br />
shared_buffers  effective_cache<br />
1024            1024            Time: 840.544 ms<br />
1024            8192            Time: 837.187 ms<br />
1024            16384           Time: 829.379 ms<br />
1024            32768           Time: 826.749 ms<br />
1024            65536           Time: 824.526 ms<br />
1024            131072          Time: 808.480 ms<br />
1024            262144          Time: 825.258 ms<br />
1024            327680          Time: 817.206 ms<br />
We can see here that the shared_buffers has the largest single affect on performance for this select statement. Would increaseing the effective cache setting while using the optimum shared bufffers chage anything?<br />
shared_buffers  effective_cache<br />
32768           1024            Time: 361.477 ms  Time: 364.341 ms<br />
32768           8192            Time: 383.347 ms  Time: 388.539 ms<br />
32768           16384           Time: 422.892 ms  Time: 425.068 ms<br />
32768           32768           Time: 356.700 ms  Time: 387.811 ms<br />
32768           65536           Time: 360.410 ms  Time: 406.472 ms<br />
32768           131072          Time: 423.960 ms  Time: 425.333 ms<br />
32768           262144          Time: 386.507 ms  Time: 392.272 ms<br />
32768           327680          Time: 383.629 ms  Time: 385.097 ms<br />
It is quite plain from above that the most important parameter between shared_buffers and effective_cache for my select query is definitely shared_buffers.<br />
Adding &#8220;order by column&#8221; and testing<br />
sort_mem<br />
1024     Time: 640.896 ms<br />
8192     Time: 582.495 ms<br />
16384    Time: 505.777 ms<br />
32768    Time: 505.784 ms<br />
We can see here that increasing the sort_mem has a good effect on performance.<br />
Now adding a simple limit clause to the sorted results gives me another boost to the procedure.<br />
limit<br />
50000    Time: 391.164 ms<br />
25000    Time: 350.564 ms<br />
10000    Time: 325.975 ms<br />
1000     Time: 311.234 ms<br />
1        Time: 309.303 ms<br />
We can see here that preparing the results has a large impact in performance. Something else that a lot of people miss is the order the columns are in, in the query used.<br />
For instance asking for the colums in the order they are in in the table we get<br />
Time: 360.379 ms<br />
If we reverse the order of three columns we get.<br />
Time: 405.506 ms<br />
This is a big difference if the query is called a lot.</p>
]]></content:encoded>
					
					<wfw:commentRss>http://127.0.0.1:8090/tuning_postgres.htm/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
