<?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>Archives des zHead - dbi Blog</title>
	<atom:link href="https://www.dbi-services.com/blog/tag/zhead/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbi-services.com/blog/tag/zhead/</link>
	<description></description>
	<lastBuildDate>Fri, 26 Oct 2018 06:37:21 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2025/05/cropped-favicon_512x512px-min-32x32.png</url>
	<title>Archives des zHead - dbi Blog</title>
	<link>https://www.dbi-services.com/blog/tag/zhead/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Deep dive Postgres at the #pgconfeu conference</title>
		<link>https://www.dbi-services.com/blog/deep-dive-postgres-at-the-pgconfeu-conference/</link>
					<comments>https://www.dbi-services.com/blog/deep-dive-postgres-at-the-pgconfeu-conference/#respond</comments>
		
		<dc:creator><![CDATA[Hervé Schweitzer]]></dc:creator>
		<pubDate>Fri, 26 Oct 2018 06:37:21 +0000</pubDate>
				<category><![CDATA[Database Administration & Monitoring]]></category>
		<category><![CDATA[MVCC]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Undo]]></category>
		<category><![CDATA[zHead]]></category>
		<guid isPermaLink="false">https://www.dbi-services.com/blog/deep-dive-postgres-at-the-pgconfeu-conference/</guid>

					<description><![CDATA[<p>Today I followed many good technical sessions at the European Postgres conference. The Postgres conferences are really technical oriented, you will find no marketing sessions there and you learn a lot of things. As promised yesterday, I wrote today my first blog about the new Postgres storage engine ZHEAP/UNDO, which is a very interesting feature, [&#8230;]</p>
<p>L’article <a href="https://www.dbi-services.com/blog/deep-dive-postgres-at-the-pgconfeu-conference/">Deep dive Postgres at the #pgconfeu conference</a> est apparu en premier sur <a href="https://www.dbi-services.com/blog">dbi Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Today I followed many good technical sessions at the European Postgres conference. The Postgres conferences are  really technical oriented, you will find no marketing sessions there and you learn a lot of things.<br />
As promised yesterday, I wrote today my first blog about the new Postgres storage engine ZHEAP/UNDO, which is a very interesting feature, with very interesting results.<br />
<span id="more-11941"></span><br />
Before you continue to read this blog, if you didn&#8217;t read my blog from yesterday,read it first <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <a href="https://www.dbi-services.com/blog/my-first-day-at-the-pgconfeu-2018-in-lisbon/" title="link" target="_blank" rel="noopener noreferrer">link</a></p>
<h3>First test : table creation</h3>
<p>We create 2 tables, one with the default Postgres storage engine HEAP, and one with the new storage enfine ZHEAP.</p>
<pre class="brush: bash; gutter: true; first-line: 1">
PSQL&gt; create table heap2 as select a.*, md5(a::varchar), now() from generate_series(1,5000000) a;
 
SELECT 5000000
Time: 12819.369 ms (00:12.819)

PSQL&gt; create table zheap2  with (storage_engine='zheap') as select a.*, md5(a::varchar), now() from generate_series(1,5000000) a;
SELECT 5000000
Time: 19155.004 ms (00:19.155)
</pre>
<p>You noticed, that with Postgres you can choose your storage engine at table level :-). The table creation with ZHEAP is slower, but is is normal because now we have to create the UNDO segment also.</p>
<h3>Second test : Size of the both tables</h3>
<p>Before to start the tests we will check the size of the HEAP and ZHEAP tables, as announced yesterday the HEAP table should be smaller, because we have less header information.</p>
<pre class="brush: bash; gutter: true; first-line: 1">
PSQL&gt;  select pg_size_pretty(pg_relation_size('heap2'));
 pg_size_pretty 
----------------
 365 MB
PSQL&gt; select pg_size_pretty(pg_relation_size('zheap2'));
 pg_size_pretty 
----------------
 289 MB
</pre>
<p>The ZHEAP tables is smaller, it exactly what Amit explain us yesterday, because the block header with ZHEAP is smaller. If you want to learn more read his presentation from yesterday. Again the link is on my blog from yesterday.</p>
<h3>Third test : Update on the table</h3>
<p>To get the bloat effect on the HEAP table, we will now update the full table and see what happen.</p>
<pre class="brush: bash; gutter: true; first-line: 1">
PSQL&gt; update heap2 set a=a+12222222;
UPDATE 5000000
Time: 19834.911 ms (00:19.835)

PSQL&gt; update zheap2 set a=a+12222222;
UPDATE 5000000
Time: 26956.043 ms (00:26.956)

PSQL&gt; select pg_size_pretty(pg_relation_size('zheap2'));
 pg_size_pretty 
----------------
 289 MB
PSQL&gt; vacuum heap2;
PSQL&gt; select pg_size_pretty(pg_relation_size('heap2'));
 pg_size_pretty 
----------------
 730 MB
</pre>
<p>The same as for the creation the update is a bit longer, but the update with ZHEAP write  many information into the log file.We should test again this update with disabling the writing of information into the log file about creating undo segment.<br />
But  as you can see, the most important information here is that the table don&#8217;t bloat as the HEAP table, now the HEAP table is 2 times bigger despite I executed a VACUUM.</p>
<h3>Fourth test: test of the ROLLBACK</h3>
<p>To test the ROLLBACK we have to open first a transaction with BEGIN;</p>
<pre class="brush: bash; gutter: true; first-line: 1">
PSQL&gt;  begin;
BEGIN
PSQL&gt;* update heap2 set a=a+12222222;
UPDATE 5000000
Time: 22071.462 ms (00:22.071)
PSQL&gt; * rollback;
ROLLBACK
Time: 1.437 ms

PSQL&gt; begin;
BEGIN
PSQL&gt; * update zheap2 set a=a+12222222;
UPDATE 5000000
Time: 28210.845 ms (00:28.211)
PSQL&gt; * rollback;
ROLLBACK
Time: 0.567 ms
</pre>
<p>This is the part where I&#8217;m the most surprised, the ROLLBACK for ZHEAP is so fast as for HEAP, I can&#8217;t explain that. I will leave my colleague Daniel Westermann making deeper tests :-). Because with ZHEAP he has to apply the undo blocks, where HEAP tables only mark the transactions as aborted.</p>
<h3>Fifth tests : Check of the query performances</h3>
<p>For this test we have to first flush the filesystem cache and to restart the database, to be sure that nothing is cached.</p>
<pre class="brush: bash; gutter: true; first-line: 1">
postgres@dbi-pg-tun:/home/postgres/zheap/ [ZHEAP] pgstop 
waiting for server to shut down.... done
server stopped

postgres@dbi-pg-tun:/home/postgres/ [ZHEAP] sudo sync
postgres@dbi-pg-tun:/home/postgres/ [ZHEAP] sudo echo 3 &gt; /proc/sys/vm/drop_caches

postgres@dbi-pg-tun:/home/postgres/zheap/ [ZHEAP] pgstart
waiting for server to start.... done
server started
</pre>
<p>Now we are ready for the last test </p>
<pre class="brush: bash; gutter: true; first-line: 1">
postgres@dbi-pg-tun:/home/postgres/zheap/ [ZHEAP] sqh
PSQL&gt; select count(*) from heap2;
  count  
---------
 5000000
Time: 3444.869 ms (00:03.445)

PSQL&gt; select count(*) from zheap2;
  count  
---------
 5000000
Time: 593.894 ms
</pre>
<p>As you can see the query performance are improved significantly for full table scan :-), because the table didn&#8217;t bloat as for the HEAP table. For you information I started additionally 2 times a full update before to restart the database and the HEAP table is now 3 times bigger.</p>
<pre class="brush: bash; gutter: true; first-line: 1">
PSQL&gt; select pg_size_pretty(pg_relation_size('heap2'));
 pg_size_pretty 
----------------
 1095 MB

Time: 0.508 ms
PSQL&gt; select pg_size_pretty(pg_relation_size('zheap2'));
 pg_size_pretty 
----------------
 289 MB
</pre>
<h3>Conclusion of these tests</h3>
<ul>
<li>Postgres allow the usage or not of UNDO&#8217;s at the table level</li>
<li>We are surprise how fast the ROLLBACK are, but this must be tested again, I don&#8217;t understand why</li>
<li>Select performance are improved significantly for full table scan <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></li>
<li>The storage will not bloat anymore with ZHEAP</li>
<li>Finally only the updates are a little bit slower</li>
</ul>
<p>It will be interesting to follow the discussions around this feature on the mailing list.</p>
<p>L’article <a href="https://www.dbi-services.com/blog/deep-dive-postgres-at-the-pgconfeu-conference/">Deep dive Postgres at the #pgconfeu conference</a> est apparu en premier sur <a href="https://www.dbi-services.com/blog">dbi Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbi-services.com/blog/deep-dive-postgres-at-the-pgconfeu-conference/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Lazy Loading (feed)

Served from: www.dbi-services.com @ 2026-10-18 13:40:33 by W3 Total Cache
-->