New and Evolving PostgreSQL Enterprise Features with Recent Releases
Tags: postgres, database, developer
Published: 2021-09-15 20:03:11

---
title: New and Evolving PostgreSQL Enterprise Features with Recent Releases
published: true
description: In this blog post we present some of the new and evolving enterprise features of the PostgreSQL DBMS that make it a real competitor to other DBMS such as Oracle
tags: PostgreSQL, database, developer
cover_image: https://scalegrid.io/blog/wp-content/uploads/2021/08/New-and-Evolving-PostgreSQL-Enterprise-Features-with-Recent-Releases-Blog.jpg
---
<link rel="canonical" href="https://scalegrid.io/blog/wp-content/uploads/2021/08/New-and-Evolving-PostgreSQL-Enterprise-Features-with-Recent-Releases-Blog.jpg" />
<p style="text-align: justify;">PostgreSQL also introduced many other breakthrough features in versions 10 through 11, 12 and 13 that make it a real competitor against Oracle, such as partitioning enhancements, parallel query and logical replication. In this blog post, we will showcase some of the new and notable PostgreSQL features included in more recent versions of PostgreSQL.</p>

<table style="border: solid 20px #def5fe;" width="100%">
<tbody>
<tr>
<th style="padding: 20px 30px 20px 30px;">
<h2 style="padding-bottom: 10px;">New &amp; Notable PostgreSQL Features</h2>
<ul>
	<li style="padding-bottom: 10px;"><a style="color: #2da964; text-decoration: underline;" href="#1">Partitioning Features</a></li>
	<li style="padding-bottom: 10px;"><a style="color: #2da964; text-decoration: underline;" href="#2">Indexing Features</a></li>
	<li style="padding-bottom: 10px;"><a style="color: #2da964; text-decoration: underline;" href="#3">Authentication</a></li>
	<li style="padding-bottom: 10px;"><a style="color: #2da964; text-decoration: underline;" href="#4">Other Notable Features</a></li>
	<li style="padding-bottom: 10px;"><a style="color: #2da964; text-decoration: underline;" href="#5">Summary</a></li>
</ul>
</th>
</tr>
</tbody>
</table>
<h2 style="padding-top: 10px;"><a id="1"></a>Partitioning Features</h2>
<h3 style="padding-top: 10px;">Declarative Partitioning</h3>
<p style="text-align: justify;">Until PostgreSQL version 9.4, there was no actual partitioning in PostgreSQL. It was achieved only through table inheritance, which offered very limited functionality and performance benefits. Much of the functionality is managed manually through triggers or SQL commands. For example, we had to use triggers to direct a row before INSERT to the correct partition. We have to create indexes for each partition separately. PostgreSQL version 10 gave birth to declarative partitioning, but we still had to create constraints and indexes for each partition.</p>
<p style="text-align: justify;"><a style="color: #2da964;" href="https://www.postgresql.org/docs/release/11.0/" target="_blank">PostgreSQL 11 comes complete with a very impressive set of new Partitioning features</a> to both help improve performance and also to help make partitioned tables more transparent to applications.</p>

<h3 style="padding-top: 10px;">Logical replication of partitioned tables</h3>
<p style="text-align: justify;">With PostgreSQL 13, they introduced support for logically replicating partitioned tables. Previously, you were forced to replicate partitions to your standbys individually. Now, however, you can automatically replicate all your partitions at the same time</p>

<h3 style="padding-top: 10px;">Partitioning Methods</h3>
<p style="text-align: justify;">The currently supported partitioning methods are range, list, and hash.</p>

<h3 style="padding-top: 10px;">Keys &amp; Indexes</h3>
<p style="text-align: justify;">Full support for foreign keys on partitioned tables was added in PostgreSQL 12. PostgreSQL also boasts support for primary keys, indexes, and triggers on partitioned tables.</p>

<h3 style="padding-top: 10px;">Default Partition</h3>
<p style="text-align: justify;">PostgreSQL allows the creation of a “default” partition for storing data that does not match any of the remaining partitions. Oracle users will love this feature as it is not available in Oracle Database.</p>

<h3 style="padding-top: 10px;">Row Movement</h3>
<p style="text-align: justify;">UPDATE statements that change a partition key column now cause affected rows to be moved to the appropriate partitions.</p>

<h3 style="padding-top: 10px;">Partition Pruning</h3>
<p style="text-align: justify;">Improve SELECT performance through enhanced partition elimination strategies during query planning and execution. A new method of performing <a style="color: #2da964;" href="https://www.postgresql.org/docs/11/ddl-partitioning.html#DDL-PARTITION-PRUNING" target="_blank">partition elimination</a> has been added. This new algorithm is able to determine matching partitions by looking at the query’s WHERE clause. The previous algorithm checked each partition, in turn, to see if it could match the WHERE clause of the query. This resulted in an additional increase in planning time as the number of partitions grew.</p>

<h3 style="padding-top: 10px;">Partition Pruning During Query Execution</h3>
<p style="text-align: justify;">As for prepared statements, query parameters are not known before the execution. Query Planner cannot eliminate partitions during the planning phase as parameters are not known. So, the executor does the partition pruning during execution to access only the partitions that match parameters.</p>

<h2 style="padding-top: 10px;"><a id="2"></a>Indexing Features</h2>
<h3 style="padding-top: 10px;">Covering Index</h3>
<p style="text-align: justify;">PostgreSQL now allows you to add non-key columns in the btree index. Since queries typically need to retrieve more columns than just the ones they search on, PostgreSQL allows you to create an index in which some columns are just “payload” and are not part of the search key. It helps in doing just <a style="color: #2da964;" href="https://www.postgresql.org/docs/11/indexes-index-only-scans.html" target="_blank">index-only scans</a> to retrieve the required rows.</p>
<h3 style="padding-top: 10px;">Reindex Concurrently</h3>
<p style="text-align: justify;">Starting PostgreSQL 12, it’s possible to rebuild an index with <a style="color: #2da964;" href="https://www.postgresql.org/docs/12/sql-reindex.html" target="_blank">REINDEX CONCURRENTLY</a> without locking the table for read/writes, just like the Oracle REBUILD INDEX command.</p>
<h3 style="padding-top: 10px;">Parallel Index Creation</h3>
<p style="text-align: justify;">With <a style="color: #2da964;" href="https://www.postgresql.org/docs/11/sql-createindex.html" target="_blank">parallel index creation</a> (Introduced in PostgreSQL 11, currently applicable only for b-tree indexes), indexes can be created faster up to max_parallel_workers value and setting maintenance_work_mem large enough to hold multiple copies of data. Parallel index creation can significantly reduce your <a style="color: #2da964;" href="https://www.cybertec-postgresql.com/en/postgresql-parallel-create-index-for-better-performance/" target="_blank">index creation time</a>.</p>
<h3 style="padding-top: 10px;">Deduplication of Data in B-Tree Indexes</h3>
<p style="text-align: justify;">Sometimes there will be duplicate entries in an index. This means that a leaf node in a B-Tree index with at least two index entries in the same index contains the same data for all the index columns. With the addition of deduplication in PostgreSQL 13, you can group these duplicate B-Tree index entries and gather them in a group entry. The benefit of this is saving space and reduced load on disk and RAM, as you won’t have to duplicate column data. Duplicate entries also cause unwanted index bloating.</p>
<h2 style="padding-top: 10px;"><a id="3"></a>Authentication</h2>
<h3 style="padding-top: 10px;">SCRAM-SHA-256</h3>
<p style="text-align: justify;">In PostgreSQL 11 came support for <a style="color: #2da964;" href="https://www.postgresql.org/docs/11/auth-password.html" target="_blank">SCRAM-SHA-256 password authentication</a>. This method prevents password sniffing on untrusted connections and allows you to store your passwords in a cryptographically hashed form.</p>
<p style="text-align: justify;">Out of all the currently supported password authentication methods, this is the most secure one.</p>
<h3 style="padding-top: 10px;">GSSAPI</h3>
<p style="text-align: justify;"><a style="color: #2da964;" href="https://www.postgresql.org/docs/11/gssapi-auth.html" target="_blank">GSSAPI</a> allows secure authentication, as well as automatic single-sign-on for systems that support it. This authentication method relies on a GSSAPI-compatible security library. The data sent over the database connection will be unencrypted unless SSL is used; however the authentication itself is secure. GSSAPI with Kerberos authentication is possible with PostgreSQL according to industry standards. When Kerberos is used, a standard principal is used in the format “servicename/hostname@realm”. Any principal included in the keytab used by the server will be accepted by the PostgreSQL server.</p>
<h3 style="padding-top: 10px;">LDAP</h3>
<p style="text-align: justify;">Operating similarly to password authentication, this authentication method uses LDAP as the verification method. It’s only used to validate username and password pairs, hence the user must exist in the database already for the authentication to work. <a style="color: #2da964;" href="https://www.postgresql.org/docs/11/auth-ldap.html" target="_blank">LDAP authentication</a> operates in either a simple bind mode or what’s called search+bind. Search+bind allows you to use other identifiers compared to the simple bind mode, which only allows the distinguished name, domain name, or email to be used.</p>
<h3 style="padding-top: 10px;">Certificate</h3>
<p style="text-align: justify;">The <a style="color: #2da964;" href="https://www.postgresql.org/docs/11/auth-cert.html" target="_blank">certificate authentication method</a> uses SSL certificates to authenticate. Consequently, it’s only available for SSL connections. With certificate authentication, no password is required. The client simply needs to provide a valid and trusted certificate to be able to authenticate. The certificate’s common name will be matched with the database user name, and if a match is found, the client will be logged in.</p>
<h2 style="padding-top: 10px;"><a id="4"></a>Other notable features</h2>
<h3 style="padding-top: 10px;">Parallel Vacuum</h3>
<p style="text-align: justify;">With the release of PostgreSQL 13, improvements to the <a style="color: #2da964;" href="https://www.postgresql.org/docs/13/sql-vacuum.html" target="_blank">VACUUM</a> command were implemented. The improvement in question is the added parameter option PARALLEL. With PARALLEL, you can perform index vacuum and index cleanup phases of VACUUM. This allows you to parallel vacuum multiple indexes corresponding to a single table.</p>
<h3 style="padding-top: 10px;">Parallel Query </h3>
<p style="text-align: justify;">Most Reports queries, which generally scan a lot of data, suffer from performance degradation due to needing to scan or aggregate data from many rows even with an index scan. These queries can use only one CPU until 9.4 and run serially.</p>
<p style="text-align: justify;">With parallel query (which offers parallel sequential scan, merge join, hash join, aggregate and other parallel query plan features), these queries can take advantage of multiple workers, and performance can improve from 2x to 10x as per <a style="color: #2da964;" href="https://www.postgresql.org/docs/11/parallel-query.html" target="_blank">documentation</a>.</p>
<p style="text-align: justify;">Check out this post to learn <a style="color: #2da964;" href="https://www.postgresql.org/docs/current/when-can-parallel-query-be-used.html" target="_blank">when to use parallel queries</a>.</p>
<h3 style="padding-top: 10px;">Native Logical Replication</h3>
<p style="text-align: justify;">PostgreSQL introduced <a style="color: #2da964;" href="https://www.postgresql.org/docs/10/logical-replication.html" target="_blank">native logical replication</a> in version 10 to provide a more flexible replication option, unlike <a style="color: #2da964;" href="https://scalegrid.io/blog/getting-started-with-postgresql-streaming-replication/" target="_blank">streaming replication</a> and more like Oracle Streams, to replicate specific tables, columns, or rows. This can be used to split between multiple databases or consolidate from multiple databases. And can also replicate between different major versions of PostgreSQL. </p>
<h3 style="padding-top: 10px;">Stored Procedures with Embedded Transactions</h3>
<p style="text-align: justify;">Yet another addition that makes PostgreSQL compatible for migrations from Oracle database.</p>
<p style="text-align: justify;">We don’t have any transaction control inside the pgsql program (DO block or function) in version 9.4, and have to use a workaround like dblink to start and commit/rollback transactions.</p>
<p style="text-align: justify;">With <a style="color: #2da964;" href="https://www.postgresql.org/docs/11/sql-createprocedure.html" target="_blank">stored procedures</a>, which premiered in version 11, we can now implement transaction control within any pgsql structure like while loop, for loop, or if else statement. Although stored procedures are similar to functions, they have to be invoked by CALL command and can work as independent programs.</p>
<h3 style="padding-top: 10px;">Generated Columns</h3>
<p style="text-align: justify;">Like Oracle database, <a style="color: #2da964;" href="https://www.postgresql.org/docs/12/ddl-generated-columns.html" target="_blank">generated columns in PostgreSQL</a> can store the data automatically computed from other columns within the row. This speeds up queries by not having to compute the value during query execution, and instead, the generated column value is computed on INSERT or UPDATE to the row.</p>
<h3 style="padding-top: 10px;">JIT Compilation</h3>
<p style="text-align: justify;">PostgreSQL 11, 12 and 13 all support <a style="color: #2da964;" href="https://www.postgresql.org/docs/current/jit-reason.html" target="_blank">Just-in-Time (JIT) compilation</a>, which was added back in 2018. JIT compilation is the process of turning an interpreted program evaluation into a native program. With JIT compilation, this process can be done at run time. An advantage of JIT is the possibility of generating expression-specific functions that the CPU can natively execute. In turn, the process gives you a speedup.</p>
<h3 style="padding-top: 10px;">Page Checksums</h3>
<p style="text-align: justify;">Page checksums is a feature that helps you verify the integrity of data stored to disk. Previously, you could only enable page checksums during the initialization of a PostgreSQL cluster. PostgreSQL 12 introduced the ability to enable or disable page checksums in an offline cluster via the pg_checksums command.</p>
<h2 style="padding-top: 10px;"><a id="5"></a>Summary</h2>
<p style="text-align: justify;">As you can see from this article, PostgreSQL is an ever-evolving database system that brings many powerful features to the table. Every new version adds new exciting features that make it a real competitor to other databases such as Oracle. Its partitioning and indexing features get many new updates that add onto its already expansive toolbox.</p>
<p style="text-align: justify;">If you are looking for a managed solution for your PostgreSQL database, feel free to check out our <a style="color: #2da964;" href="https://scalegrid.io/postgresql.html" target="_blank">ScaleGrid for PostgreSQL</a> service. We provide a <a style="color: #2da964;" href="https://console.scalegrid.io/users/register" target="_blank">free 30-day trial</a> that allows you to use all our management features with no restrictions. Pricing starts at just <a style="color: #2da964;" href="https://scalegrid.io/pricing.html?db=POSTGRESQL&cloud=cloud_digital_ocean&replica=deployment_standalone&instance=Nano#section_pricing_dedicated" target="_blank">$10/month</a> and gives you access to a fully managed enterprise-grade PostgreSQL hosting solution with 24/7 support.</p>