Skip to content

This is the multi-page printable view of this section.

Return to the regular view of this page

Overview

Understand transparent data encryption, pg_tde, supported deployments, and its limits.

This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see PG TDE on Mimus.

PG.CENTER edition · Upstream source

1 - About Transparent Data Encryption

An introduction to transparent encryption of data stored on disk.

This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see PG TDE on Mimus.

Transparent Data Encryption (TDE) protects your data at rest by ensuring that even if the underlying storage is compromised, the data remains unreadable without the correct decryption keys. This is especially critical for environments handling sensitive, regulated, or high-value information.

This process runs transparently in the background, with minimal impact on database operations.

Use the links below to explore how pg_tde helps secure your PostgreSQL deployments:

Discover the benefits of pg_tde Understand pg_tde limitations View the full feature list Get started with installation

PG.CENTER edition · Upstream source

2 - How pg_tde works

How pg_tde applies encryption within the PostgreSQL storage path.

This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see PG TDE on Mimus.

To encrypt the data, two types of keys are used:

  • Internal encryption keys to encrypt user data. They are stored internally, near the data that they encrypt.
  • The principal key to encrypt database keys. It is kept separately from the database keys and is managed externally in the key management store.
Note

For more information on managing and storing principal keys externally, including supported key management systems and the local keyring option, see Key management overview.

The encryption process works as follows:

image

When a user creates an encrypted table using pg_tde, a new random key is generated internally for that table and is encrypted using the AES-CBC cipher algorithm. This key is used to encrypt all data the user inserts in that table. Eventually the encrypted data gets stored in the underlying storage.

The internal key itself is encrypted using the principal key. The principal key is stored externally in the key management store.

Similarly when the user queries the encrypted table, the principal key is retrieved from the key store to decrypt the internal key. Then the same unique internal key for that table is used to decrypt the data, and unencrypted data gets returned to the user. So, effectively, every TDE table has a unique key, and each table key is encrypted using the principal key.

Understand the encrypted data scope

PG.CENTER edition · Upstream source

3 - Benefits of pg_tde

Where database-level encryption complements other protections for stored data.

This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see PG TDE on Mimus.

The benefits of using pg_tde are outlined below for different users and organizations.

Benefits for organizations

  • Data safety: Prevents unauthorized access to stored data, even if backup files or storage devices are stolen or leaked.
  • Enterprise-ready Architecture: Supports both single and multi-tenancy, giving flexibility for SaaS providers or internal multi-user systems.

Benefits for DBAs and engineers

  • Granular control: Encrypt specific tables or databases instead of the entire system, reducing performance overhead.
  • Operational simplicity: Works transparently without requiring major application changes.
  • Defense in depth: Adds another layer of protection to existing controls like TLS (encryption in transit), access control, and role-based permissions.

When combined with the external Key Management Systems (KMS), pg_tde enables centralized control, auditing, and rotation of encryption keys—critical for secure production environments.

See also

You can find more information on Transparent Data Encryption (TDE) in this article.

Learn how pg_tde works

PG.CENTER edition · Upstream source

4 - Encrypted data scope

Identify encrypted data files, WAL, and the information that remains unencrypted.

This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see PG TDE on Mimus.

pg_tde encrypts the following components:

  • User data in tables using the extension, including associated TOAST data. The table metadata (column names, data types, etc.) is not encrypted.
  • Temporary tables created during the query execution, for data tables created using the extension.
  • Write-Ahead Log (WAL) data for the entire database cluster. This includes WAL data in encrypted and non-encrypted tables.
  • Indexes on encrypted tables.

Check out the table access methods

PG.CENTER edition · Upstream source

5 - Table access methods and pg_tde

Use tde_heap explicitly or as the default access method for new tables.

This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see PG TDE on Mimus.

A table access method is the way how PostgreSQL stores the data in a table. The default table access method is heap. PostgreSQL organizes data in a heap structure, meaning there is no particular order to the rows in the table. Each row is stored independently and identified by its unique row identifier (TID).

How the heap access method works

Insertion: When a new row is inserted, PostgreSQL finds a free space in the tablespace and stores the row there.

Deletion: When a row is deleted, PostgreSQL marks the space occupied by the row as free, but the data remains until it is overwritten by a new insertion.

Updates: PostgreSQL handles updates by deleting the old row and inserting a new row with the updated values.

Custom access method

Custom access methods allow you to implement and define your own way of organizing data in PostgreSQL. This is useful if the default table access method doesn’t meet your needs.

Custom access methods are typically available with PostgreSQL extensions. When you install an extension and enable it in PostgreSQL, a custom access method is created.

An example of such an approach is the tde_heap access method. It is automatically created only for the databases where you enabled the pg_tde extension and configured the key provider, enabling you to encrypt the data.

To use a custom access method, specify the USING clause for the CREATE TABLE command:

CREATE TABLE table_name (
    column1 data_type,
    column2 data_type,
    ...
) USING tde_heap;

How tde_heap works with pg_tde

The tde_heap access method works on top of the default heap access method and is a marker to point which tables require encryption. It uses the custom storage manager TDE SMGR, which becomes active only after you installed the pg_tde extension.

Every data modification operation is first sent to the Buffer Manager, which updates the buffer cache. Then, it is passed to the storage manager, which then writes it to disk. When a table requires encryption, the data is sent to the TDE storage manager, where it is encrypted before written to disk.

Similarly, when a client queries the database, the PostgreSQL core sends the request to the Buffer Manager which checks if the requested data is already in the buffer cache. If it’s not there, the Buffer Manager requests the data from the storage manager. The TDE storage manager reads the encrypted data from disk, decrypts it and loads it to the buffer cache. The Buffer Manager sends the requested data to the PostgreSQL core and then to the client.

Thus, the encryption is done at the storage manager level.

Changing the default table access method

You can change the default table access method so that every table in the entire database cluster is created using the custom access method. For example, you can enable data encryption by default by defining the tde_heap as the default table access method.

However, consider the following before making this change:

  • This is a global setting and applies across the entire database cluster and not just a single database. We recommend setting it with caution because all tables and materialized views created without an explicit access method in their CREATE statement will default to the specified table access method.
  • You must create the pg_tde extension and configure the key provider for all databases before you modify the configuration. Otherwise PostgreSQL won’t find the specified access method and will throw an error.

Here is how you can set the new default table access method:

  1. Add the access method to the default_table_access_method parameter:

    Use ALTER SYSTEM, it requires superuser or ALTER SYSTEM privileges.

    ALTER SYSTEM SET default_table_access_method = tde_heap;

    Edit the postgresql.conf configuration file and add the value for the default_table_access_method parameter.

    default_table_access_method = 'tde_heap'

    You can use the SET command to change the default table access method temporarily, for the current session.

    Unlike modifying the postgresql.conf file or using the ALTER SYSTEM command, the changes you make via the SET command don’t persist after the session ends.

    You also don’t need to have the superuser privileges to run the SET command.

    You can run the SET command anytime during the session.

    SET default_table_access_method = tde_heap;
  2. Reload the configuration to apply the changes:

    SELECT pg_reload_conf();

Understand pg_tde’s limitations

PG.CENTER edition · Upstream source

6 - Impact of pg_tde on database operations

What changes for applications, database operations, performance, and upgrades.

This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see PG TDE on Mimus.

This page summarizes how pg_tde interacts with core PostgreSQL operations.

AreaAffectedNotes / Actions
Backups❌ YesEncrypted backups require pg_tde-aware tools. See Backup with WAL encryption.
Restore❌ YesRestored data remains encrypted; pg_tde transparently handles decryption. See Restore encrypted backups.
Streaming replication⚠️ PartialReplicas must load the pg_tde shared library (shared_preload_libraries = ‘pg_tde’). Without it, the replica will fail on operations involving tde_heap.
Logical replication✅ NoNot affected.
Monitoring and statistics✅ NoNot affected, including pg_stat_monitor.
Performance⚠️ SlightMinor CPU overhead due to enabling encryption, most noticeable on random write workloads.

PG.CENTER edition · Upstream source

7 - Supported PostgreSQL deployments

Check supported PostgreSQL distributions and the status of each supported major version.

The packages and support matrix below belong to Percona PostgreSQL. Build pg_tde against the matching Mimus installation before enabling it. Mimus procedure

The pg_tde extension is available for Percona Server for PostgreSQL 17.5 and later versions, an open source, drop-in replacement for PostgreSQL Community. These versions provide the tde_heap access method and offer full encryption capabilities, including encryption of tables, indexes and WAL data.

For users who need pg_tde in PostgreSQL 16, a build is available as a Tech Preview. It is not officially supported, is not recommended for production, and does not follow the same release cadence as the supported PostgreSQL 17.5 and later versions.

The extension is tightly integrated with Percona Server for PostgreSQL to deliver enhanced encryption functionality that is not available in community builds.

Why choose Percona Server for PostgreSQL?

By using our PostgreSQL distribution, you get:

  • Full encryption support through the tde_heap access method, including tables, indexes and WAL data.
  • Enhanced performance and enterprise-ready features not available in community builds.
  • Regular updates and security patches backed by Percona’s expert support team.
  • Professional support and guidance for secure PostgreSQL deployments.
Note

Support for earlier or limited versions of pg_tde (such as tde_heap_basic) has been deprecated.

Still unsure which deployment fits your needs? Contact our experts to find the best solution for your environment.

Get started with installation

PG.CENTER edition · Upstream source

8 - Limitations of pg_tde

Review unencrypted data, unsupported operations, and WAL tool compatibility.

This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see PG TDE on Mimus.

Known incompatibilities in Percona Server for PostgreSQL

Some PostgreSQL extensions may not work with Percona Server for PostgreSQL due to internal changes required by pg_tde.

These incompatibilities may occur even if pg_tde is not installed or enabled.

Distributed and extension-based systems

Citus and TimescaleDB are not supported

Percona Server for PostgreSQL is not compatible with distributed PostgreSQL extensions such as Citus or time-series extensions such as TimescaleDB.

This limitation is caused by internal PostgreSQL changes related to pg_tde and is not dependent on enabling the extension.

Limitations when using pg_tde

Limitations of pg_tde 2.3.0:

  • PostgreSQL’s internal system tables, which include statistics and metadata, are not encrypted.
  • Temporary files created when queries exceed work_mem are not encrypted. These files may persist during long-running queries or after a server crash which can expose sensitive data in plaintext on disk.

Recovery without pg_tde in shared_preload_libraries

Risk of corruption when recovering encrypted clusters without pg_tde loaded

When recovering a PostgreSQL cluster that contains encrypted tables, the pg_tde extension must be loaded through the shared_preload_libraries configuration parameter.

ALTER DATABASE ... SET TABLESPACE

Changing a database tablespace has limited support with pg_tde

The ALTER DATABASE ... SET TABLESPACE command bypasses PostgreSQL’s storage manager (SMGR), which pg_tde relies on to enforce encryption.

  • If encrypted objects exist in the database’s default tablespace, the operation is refused.
  • If no encrypted objects are present in the default tablespace, the operation is allowed.

Only objects in the default tablespace are checked. Objects in other tablespaces are not evaluated by pg_tde.

To move encrypted tables individually, use ALTER TABLE ... SET TABLESPACE, which operates through SMGR and is compatible with pg_tde.

Currently unsupported WAL tools

The following tools are currently unsupported with pg_tde WAL encryption:

  • pg_createsubscriber
  • pg_receivewal
  • Barman
  • pg_verifybackup by default fails with checksum or WAL key size mismatch errors. As a workaround, use -s (skip checksum) and -n (--no-parse-wal) to verify backups.
  • pgBackRest without pg_tde_archive_decrypt and pg_tde_restore_encrypt, or with archive-async, archive-header-check, or checksum-page enabled.

Supported WAL tools

The following tools have been tested and verified by Percona to work with pg_tde WAL encryption:

  • Patroni, for an example configuration see the following Patroni configuration file
  • pg_tde_basebackup (with --wal-method=stream or --wal-method=none), for details on using pg_tde_basebackup with WAL encryption, see Backup with WAL encryption enabled
  • pg_tde_resetwal
  • pg_tde_rewind
  • pg_tde_upgrade
  • pg_tde_waldump
  • pgBackRest, when pg_tde_archive_decrypt and pg_tde_restore_encrypt are configured and archive-async, archive-header-check, and checksum-page are disabled

Example Patroni configuration

The following is a Percona-tested example configuration.

Click to expand the Percona-tested Patroni configuration
# Example Patroni configuration file maintained by Percona
# Source: https://github.com/jobinau/pgscripts/blob/main/patroni/patroni.yml
scope: tde
name: pg1
restapi:
  listen: 0.0.0.0:8008
  connect_address: pg1:8008
etcd3:
  host: etcd1:2379
bootstrap:
  dcs:
    ttl: 30
    loop_wait: 10
    retry_timeout: 10
    maximum_lag_on_failover: 1048576
    postgresql:
      use_pg_rewind: true
      use_slots: true
      parameters:
        archive_command: "/lib/postgresql/17/bin/pg_tde_archive_decrypt %f %p \"pgbackrest --stanza=tde archive-push %%p\""
        archive_timeout: 600s
        archive_mode: "on"
        logging_collector: "on"
        restore_command: "/lib/postgresql/17/bin/pg_tde_restore_encrypt %f %p \"pgbackrest --stanza=tde archive-get %%f \\\"%%p\\\"\""
      pg_hba:
        - local all all peer
        - host all all 0.0.0.0/0 scram-sha-256
        - host all all ::/0 scram-sha-256
        - local replication all peer
        - host replication all 0.0.0.0/0 scram-sha-256
        - host replication all ::/0 scram-sha-256
  initdb:
    - encoding: UTF8
    - data-checksums
    - set: shared_preload_libraries=pg_tde
  post_init: /usr/local/bin/setup_cluster.sh
postgresql:
  listen: 0.0.0.0:5432
  connect_address: pg1:5432
  data_dir: /var/lib/postgresql/patroni-17
  bin_dir: /lib/postgresql/17/bin
  bin_name:
    pg_basebackup: pg_tde_basebackup
    pg_rewind: pg_tde_rewind
  pgpass: /var/lib/postgresql/patronipass
  authentication:
    replication:
      username: replicator
      password: <replication-password>
    superuser:
      username: postgres
      password: <superuser-password>
  parameters:
    unix_socket_directories: /tmp
    # Use unix_socket_directories: /var/run/postgresql for Debian/Ubuntu distributions
watchdog:
  mode: off
tags:
  nofailover: false
  noloadbalance: false
  clonefrom: false
  nosync: false
Warning

The above example is Percona-tested, but Patroni versions differ, especially with discovery backends such as etcd. Ensure you adjust the configuration to match your environment, version, and security requirements.

Next steps

Check which PostgreSQL versions and deployment types are compatible with pg_tde before planning your installation.

View the versions and supported deployments

Begin the installation process when you’re ready to set up encryption.

Start installing pg_tde

PG.CENTER edition · Upstream source