<?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>max_parallel_workers_per_gather &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/max_parallel_workers_per_gather/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Tue, 22 Nov 2016 18:02:32 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.4</generator>
	<item>
		<title>PostgreSQL 9.6: Powerful Parallel Query Processing &#8211; Full Performance Test</title>
		<link>https://www.dbrnd.com/2016/11/postgresql-9-6-powerful-parallel-query-processing-full-performance-test-max_worker_processes-max_parallel_workers_per_gather/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 21 Nov 2016 18:02:01 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Increase the Performance]]></category>
		<category><![CDATA[max_parallel_workers_per_gather]]></category>
		<category><![CDATA[max_worker_processes]]></category>
		<category><![CDATA[min_parallel_relation_size]]></category>
		<category><![CDATA[Parallel CPU Usage]]></category>
		<category><![CDATA[Parallel Query Processing]]></category>
		<category><![CDATA[parallel_setup_cost]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL 9.6]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3889</guid>

					<description><![CDATA[A most awaited feature, The Powerful Parallel Sequential Query Scan feature introduced in PostgreSQL 9.6. You can easily set the Parallel Sequential parameter&#8217;s value and can execute your queries 10 times faster. When we are talking about Parallel Sequential Scanning, in background multiple workers or CPU threads are responsible for executing one single query. In [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F11%2Fpostgresql-9-6-powerful-parallel-query-processing-full-performance-test-max_worker_processes-max_parallel_workers_per_gather%2F&amp;linkname=PostgreSQL%209.6%3A%20Powerful%20Parallel%20Query%20Processing%20%E2%80%93%20Full%20Performance%20Test" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F11%2Fpostgresql-9-6-powerful-parallel-query-processing-full-performance-test-max_worker_processes-max_parallel_workers_per_gather%2F&amp;linkname=PostgreSQL%209.6%3A%20Powerful%20Parallel%20Query%20Processing%20%E2%80%93%20Full%20Performance%20Test" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F11%2Fpostgresql-9-6-powerful-parallel-query-processing-full-performance-test-max_worker_processes-max_parallel_workers_per_gather%2F&amp;linkname=PostgreSQL%209.6%3A%20Powerful%20Parallel%20Query%20Processing%20%E2%80%93%20Full%20Performance%20Test" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F11%2Fpostgresql-9-6-powerful-parallel-query-processing-full-performance-test-max_worker_processes-max_parallel_workers_per_gather%2F&amp;linkname=PostgreSQL%209.6%3A%20Powerful%20Parallel%20Query%20Processing%20%E2%80%93%20Full%20Performance%20Test" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F11%2Fpostgresql-9-6-powerful-parallel-query-processing-full-performance-test-max_worker_processes-max_parallel_workers_per_gather%2F&amp;linkname=PostgreSQL%209.6%3A%20Powerful%20Parallel%20Query%20Processing%20%E2%80%93%20Full%20Performance%20Test" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F11%2Fpostgresql-9-6-powerful-parallel-query-processing-full-performance-test-max_worker_processes-max_parallel_workers_per_gather%2F&amp;linkname=PostgreSQL%209.6%3A%20Powerful%20Parallel%20Query%20Processing%20%E2%80%93%20Full%20Performance%20Test" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F11%2Fpostgresql-9-6-powerful-parallel-query-processing-full-performance-test-max_worker_processes-max_parallel_workers_per_gather%2F&#038;title=PostgreSQL%209.6%3A%20Powerful%20Parallel%20Query%20Processing%20%E2%80%93%20Full%20Performance%20Test" data-a2a-url="https://www.dbrnd.com/2016/11/postgresql-9-6-powerful-parallel-query-processing-full-performance-test-max_worker_processes-max_parallel_workers_per_gather/" data-a2a-title="PostgreSQL 9.6: Powerful Parallel Query Processing – Full Performance Test"></a></p><h2>A most awaited feature, The Powerful Parallel Sequential Query Scan feature introduced in PostgreSQL 9.6.</h2>
<blockquote><p>You can easily set the Parallel Sequential parameter&#8217;s value and can execute your queries 10 times faster.<br />
When we are talking about Parallel Sequential Scanning, in background multiple workers or CPU threads are responsible for executing one single query.</p>
<p><img fetchpriority="high" decoding="async" class="alignright wp-image-3894 size-full" title="postgresql parallel query processing" src="https://www.dbrnd.com/wp-content/uploads/2016/11/PostgreSQLParallelQueryProcessing.png" alt="postgresqlparallelqueryprocessing" width="256" height="256" srcset="https://www.dbrnd.com/wp-content/uploads/2016/11/PostgreSQLParallelQueryProcessing.png 256w, https://www.dbrnd.com/wp-content/uploads/2016/11/PostgreSQLParallelQueryProcessing-150x150.png 150w" sizes="(max-width: 256px) 100vw, 256px" /></p></blockquote>
<blockquote><p>In the PostgreSQL 9.6, You can change the Process Workers parameter value which is default 8. (Using max_worker_processes parameter)</p></blockquote>
<blockquote><p>
<strong>Important Note:</strong><br />
If you want to increase Parallel Process Worker parameter value, You should make sure about your total CPU usage because More Parallel Process Worker required More CPU.<br />
Once you change the parameter value, You must restart the PostgreSQL service.</p></blockquote>
<blockquote data-secret="t1RdDyDsMt" class="wp-embedded-content"><p><a href="https://www.dbrnd.com/2016/11/database-theory-what-is-parallel-query-processing-parallel-database-system/">Database Theory: What is Parallel Query Processing (Parallel Database System)?</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/11/database-theory-what-is-parallel-query-processing-parallel-database-system/embed/#?secret=t1RdDyDsMt" data-secret="t1RdDyDsMt" width="600" height="338" title="&#8220;Database Theory: What is Parallel Query Processing (Parallel Database System)?&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe><br />
<strong>The details about new Parallel Sequential Parameters:</strong></p>
<blockquote><p><strong>max_worker_processes:</strong> Total number of background workers limited by this parameter. (Default: 8)<br />
<strong>max_parallel_workers_per_gather:</strong> Total number of workers that can assist a sequential scan.<br />
<strong>parallel_setup_cost:</strong> used to estimate the cost of instantiate a worker.<br />
<strong>min_parallel_relation_size:</strong> You can define the minimum size of the relation and only those relations will consider for additional workers.<br />
<strong>parallel_tuple_cost:</strong> used to estimate the cost of transferring a tuple from one worker to another.</p></blockquote>
<p><strong>Below is a full demonstration of this:</strong></p>
<blockquote><p>Prepared different result set by changing the max_parallel_workers_per_gather parameter value and once you change the value of this parameter, please do not forget to restart PostgreSQL Service. (You can find this parameter in postgresql.conf)</p></blockquote>
<blockquote><p>For each execution result, You should compare the value of &#8220;Execution time&#8221;.&#8217;</p></blockquote>
<p><strong>First create one sample table:</strong><br />
<pre class="crayon-plain-tag">CREATE TABLE tbl_ItemTransactions 
 (
     TranID SERIAL
     ,TransactionDate TIMESTAMPTZ
     ,TransactionName TEXT
 );</pre>
<strong>Insert Millions of data to test the performance of BRIN Index:</strong><br />
<pre class="crayon-plain-tag">INSERT INTO tbl_ItemTransactions 
(TransactionDate, TransactionName)
SELECT x, 'dbrnd' 
FROM generate_series('2014-01-01 00:00:00'::timestamptz, '2016-08-01 00:00:00'::timestamptz,'2 seconds'::interval) a(x);</pre>
<strong>Check the total size of table:</strong><br />
<pre class="crayon-plain-tag">SELECT pg_size_pretty(pg_total_relation_size('tbl_ItemTransactions')) AS TableSize;
-- total size "2028 MB"</pre>
<strong>Check the execution plan of below query, where max_parallel_workers_per_gather = 0:</strong><br />
<pre class="crayon-plain-tag">EXPLAIN ANALYZE SELECT COUNT(1) FROM tbl_ItemTransactions;</pre>
<strong>Result:</strong><br />
<pre class="crayon-plain-tag">"Aggregate  (cost=768697.65..768697.66 rows=1 width=8) 
(actual time=59863.028..59863.029 rows=1 loops=1)"
"  -&gt;  Seq Scan on tbl_itemtransactions  
(cost=0.00..666853.32 rows=40737732 width=0) 
(actual time=0.825..30647.470 rows=40737601 loops=1)"
"Planning time: 0.079 ms"
"Execution time: 59863.095 ms"</pre>
<strong>Check the execution plan of below query, where max_parallel_workers_per_gather = 2:</strong><br />
<pre class="crayon-plain-tag">EXPLAIN ANALYZE SELECT COUNT(1) FROM tbl_ItemTransactions;</pre>
<strong>Result:</strong><br />
<pre class="crayon-plain-tag">"Finalize Aggregate  (cost=472651.90..472651.91 rows=1 width=8) 
(actual time=21129.508..21129.511 rows=1 loops=1)"
"  -&gt;  Gather  (cost=472651.69..472651.90 rows=2 width=8) 
(actual time=21129.213..21129.492 rows=3 loops=1)"
"        Workers Planned: 2"
"        Workers Launched: 2"
"        -&gt;  Partial Aggregate  (cost=471651.69..471651.70 rows=1 width=8) 
(actual time=21102.175..21102.176 rows=1 loops=3)"
"              -&gt;  Parallel Seq Scan on tbl_itemtransactions  
(cost=0.00..429216.55 rows=16974055 width=0) 
(actual time=0.048..10929.919 rows=13579200 loops=3)"
"Planning time: 0.052 ms"
"Execution time: 21132.005 ms"</pre>
<strong>Check the execution plan of below query, where max_parallel_workers_per_gather = 4:</strong><br />
<pre class="crayon-plain-tag">EXPLAIN ANALYZE SELECT COUNT(1) FROM tbl_ItemTransactions;</pre>
<strong>Result:</strong><br />
<pre class="crayon-plain-tag">"Finalize Aggregate  (cost=387781.83..387781.84 rows=1 width=8) 
(actual time=16212.360..16212.361 rows=1 loops=1)"
"  -&gt;  Gather  (cost=387781.41..387781.82 rows=4 width=8) 
(actual time=16211.487..16212.347 rows=5 loops=1)"
"        Workers Planned: 4"
"        Workers Launched: 4"
"        -&gt;  Partial Aggregate  (cost=386781.41..386781.42 rows=1 width=8) 
(actual time=16159.409..16159.409 rows=1 loops=5)"
"              -&gt;  Parallel Seq Scan on tbl_itemtransactions  
(cost=0.00..361320.33 rows=10184433 width=0) 
(actual time=0.043..9301.194 rows=8147520 loops=5)"
"Planning time: 0.050 ms"
"Execution time: 13516.982 ms"</pre>
<strong>Check the execution plan of below query, where max_parallel_workers_per_gather = 6:</strong><br />
<pre class="crayon-plain-tag">EXPLAIN ANALYZE SELECT COUNT(1) FROM tbl_ItemTransactions;</pre>
<strong>Result:</strong><br />
<pre class="crayon-plain-tag">"Finalize Aggregate  (cost=345346.90..345346.91 rows=1 width=8) 
(actual time=16514.376..16514.377 rows=1 loops=1)"
"  -&gt;  Gather  (cost=345346.27..345346.88 rows=6 width=8) 
(actual time=16511.341..16514.351 rows=7 loops=1)"
"        Workers Planned: 6"
"        Workers Launched: 6"
"        -&gt;  Partial Aggregate  (cost=344346.27..344346.28 rows=1 width=8) 
(actual time=16358.386..16358.387 rows=1 loops=7)"
"              -&gt;  Parallel Seq Scan on tbl_itemtransactions  
(cost=0.00..327372.22 rows=6789622 width=0) 
(actual time=0.055..9956.567 rows=5819657 loops=7)"
"Planning time: 0.034 ms"
"Execution time: 10288.810 ms"</pre>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
