Running Temporal persistence on PostgreSQL: what the integration does
A team self-hosting Temporal has to choose a persistence database before anything else runs, and PostgreSQL is a tested persistence store for Temporal, with the schema set up using temporal-sql-tool. The integration works through the SQL persistence settings in the Temporal Server configuration, which point the server's history, namespace and task storage at a PostgreSQL database. Temporal's persistence docs list PostgreSQL 13 to 16 as tested versions, so the first check is whether your target major version falls inside that range, and whether the Temporal release you plan to run still documents that version as supported. Confirm both against the Temporal persistence documentation before you provision anything.
Persistence holds workflow state, event history and task queue data. It is separate from advanced visibility, which indexes workflow executions for search and can use a different store such as Elasticsearch, OpenSearch or, on supported releases, PostgreSQL itself. Mixing the two in planning is a common mistake: the persistence database decides whether workflows can run and recover, while the visibility store only affects search and listing. Because every workflow state transition is written there, the database becomes a critical dependency. If it is unavailable, workflows stop progressing, and its backup, failover and capacity design determine how much history you can recover after an incident.
SQLite is only for development and testing, so it should never back a production Temporal Service. Treat the PostgreSQL decision as a production architecture choice: agree who owns the database, which major version you will run, how upgrades and schema changes will be coordinated with Temporal Server upgrades, and how the database will be backed up and restored. Those decisions shape the sections that follow on schema setup, sizing and high availability, and they should be written down before the first workflow is deployed.
What you need before connecting Temporal to PostgreSQL
Connecting self-hosted Temporal to PostgreSQL depends on four things lining up: the server version, the Helm chart, the PostgreSQL version and the access model. Confirm each one before a schema is created, because changing them later means repeating schema and upgrade work. The cards below cover the decisions and checks that most often block a first deployment.
Tested PostgreSQL versions
Temporal's persistence testing covers PostgreSQL 13 to 16. PostgreSQL's own support windows are wider and currently list 14 through 18 as supported, with 14 ending November 12, 2026. Choose a major version that Temporal tests and that is still inside PostgreSQL's support window for the whole planned life of the cluster. Ask the Temporal release notes for your target server version whether newer PostgreSQL majors are covered before you commit to one.
Persistence docsServer version and Helm chart pairing
Temporal Server v1.32.1 was the latest release at the time of writing, with patch releases v1.31.4 and v1.30.8 for earlier minor lines. Helm chart versions below 0.73.1 do not work with server images 1.30 and later, so pin the chart and the image together. Confirm the target version against the release notes before installation, and plan to move one minor version at a time for future upgrades.
Temporal releasesDatabase account with schema rights
Create a dedicated PostgreSQL role for Temporal and separate it from the account used by the running services where possible. Schema setup with temporal-sql-tool needs rights to create and alter tables, so the setup role may need more privilege than the runtime role. Ask your database team who holds the setup credential, where it is stored and when it is rotated, and confirm the role can be removed after the initial schema is in place.
Network reachability limited to Temporal
Temporal services should run on hosts that are not reachable from the public internet. Allow connections to the PostgreSQL port only from the subnets or pods that run Temporal services, and confirm that application workloads and administrator networks reach the database through their own approved paths. Check that any PgBouncer or load balancer in front of PostgreSQL forwards connections only from those sources.
Deployment guideTLS certificates for database connections
Plan the certificate authority, server certificate and client certificates before the first connection test. PostgreSQL supports certificate-based client authentication, and your security team will likely require encrypted connections between Temporal services and the database. Confirm the certificate lifetime, the renewal process and how a rotated certificate reaches every Temporal pod or host without a full outage.
Authentication methodsAuthentication method and password hashing
Use SCRAM password authentication rather than the MD5 method, which PostgreSQL 18 has deprecated. Record which authentication method the pg_hba.conf file applies to the Temporal role and confirm that the Temporal configuration supplies the matching credential. Decide who owns password rotation and whether the credential comes from a secrets manager rather than a static file.
How to configure PostgreSQL persistence in the right order
This sequence takes a self-hosted Temporal Service from an empty PostgreSQL instance to a verified, running cluster with a schema version you can query and a database plan for backups and replicas.
Confirm the PostgreSQL version against the tested range
Before any installation, check the PostgreSQL major version against Temporal's tested persistence range, which covers PostgreSQL 13 to 16 in the supplied facts. Also check the Temporal Server release you plan to run, since the persistence documentation is tied to specific server lines. Confirm the chosen version against the current persistence page, because PostgreSQL 13 is unsupported by the PostgreSQL project. Done when the version pair is written down and approved by the platform owner, with a note of the Temporal and PostgreSQL versions you will upgrade to later.
Create the database and roles
A database administrator creates a dedicated database for the Temporal persistence store and separate roles for schema administration and runtime access. The schema role needs rights to create and alter tables, while the server role should be limited to the data it needs. Use the authentication method your security standards require, and confirm that SCRAM is in use rather than MD5 password authentication. Done when you can connect as each role from the host that will run the schema tool and from the Temporal service hosts, and when a test login as the runtime role cannot alter the schema.
Create and set up the schema with temporal-sql-tool
Run temporal-sql-tool with the schema administration role to create the persistence schema, then apply the current schema setup for your Temporal Server release. Keep the command, its configuration values and the release it was run for in version control so the same steps can be repeated in each environment. Schema setup must match the server version you deploy, so run it before starting any server process. Done when a query against the schema version table returns the expected version for the release you are deploying.
Point the server persistence configuration at PostgreSQL
Update the Temporal Server persistence configuration to use the PostgreSQL driver, the host, the port, the database name and the runtime role. Store the password in your secrets manager and inject it at startup rather than writing it into the configuration file. Set connection limits with your database team, because each service connects to the store. Done when the configuration passes a review against the self-hosted deployment documentation and the values match the database you created in the previous steps.
Start the services and verify health
Start the Temporal Server services using your chosen deployment method, whether Docker Compose, binaries or Helm charts on Kubernetes. Check that the frontend, history, matching and worker services start without persistence errors in their logs. Then query the frontend health endpoint and confirm that the default namespace is listed. Keep the Temporal services off public networks, as the deployment documentation recommends. Done when all services report healthy and the logs show no schema or connection errors.
Run a test workflow to confirm end-to-end execution
Deploy a small test workflow and activity with a Temporal SDK, start it through the client, and confirm that it completes. Inspect the workflow history in the Web UI or with the CLI, and confirm that the events were written to the PostgreSQL store. If you run advanced visibility on another store, confirm the search results separately. Done when the test workflow reaches the completed state, its history is visible, and the expected rows appear in the database.
Add backups and plan replicas
Set up regular backups of the Temporal database and test a restore into a separate environment. PostgreSQL's documentation describes continuous archiving and point-in-time recovery, which your database team should evaluate against your recovery requirements. Plan hot standby replicas and decide between synchronous and asynchronous replication, since PostgreSQL does not provide automatic failover on its own and you must select external tooling. Confirm the choices with your database team and record the recovery procedure. Done when a restore has been tested and the failover design has been signed off.
How Temporal services, the schema tool and PostgreSQL connect
The diagram starts with the operator running temporal-sql-tool during setup, which creates the schema in the PostgreSQL persistence database before any service starts. Inside the internal network boundary, the frontend receives client and worker requests and hands work to the history and matching services, which read and write state in PostgreSQL. Check that every Temporal service and the database sit inside the trust boundary, and that no path reaches them from the public internet.
Setup tool, Temporal services and PostgreSQL inside one internal network boundary.
Sizing the database and planning its high availability
Sizing a Temporal database starts from the workload, not from a template. Temporal stores workflow history, task queue state and execution metadata in the persistence store, so database load grows with the number of workflow executions, the number of events each execution records and the number of history shards the cluster is configured with. Ask your Temporal design team to estimate the event volume per workflow type, then multiply by expected starts per day and retention period. Treat that estimate as a starting point and validate it with a load test against a representative build.
- Workflow history volume: Long workflows with many activities and timers produce more history rows than short ones, so event count per execution matters more than execution count alone.
- Shard count: The number of history shards is set when a cluster is created and affects how work spreads across database connections. Confirm the value with your Temporal scaling plan before you size the database.
- Connection counts: Each Temporal service opens its own pool of connections. Count connections per service and per replica, then plan a PgBouncer layer if the total approaches what the PostgreSQL server can serve well.
- Storage growth and retention: Retention settings determine how long closed workflow data stays in the database. Measure daily growth in a test namespace, then project it across the retention window and add room for vacuum overhead and backups.
- Measured baselines: Record CPU, memory, IOPS and latency under peak load before you commit to instance sizes, and repeat the measurement after any change to workflow design.
Before you finalize sizing, confirm the retention period, peak start rate and shard count with the team that owns the Temporal workload.
PostgreSQL supports hot standby servers that answer read-only queries and two replication modes. With synchronous replication, a commit on the primary waits until one or more standbys confirm it, which protects committed Temporal state from loss at the cost of added commit latency and a dependency on standby availability. With asynchronous replication, the primary does not wait, so commit latency stays low, but the most recent transactions may be lost if the primary fails before they reach a standby. Your choice depends on how much workflow state you can afford to lose and how much latency your workers can absorb.
- Synchronous mode: Protects committed history at the cost of write latency. Measure commit latency with a standby in the target network path, including any cross-zone link.
- Asynchronous mode: Keeps write latency low but accepts a window of possible loss. Document the window and the recovery steps that reconcile workflow state after a failover.
- Standby count: Decide how many standbys must confirm a commit when synchronous replication is used, since that number affects both durability and availability.
- Read-only queries: Temporal's persistence layer is write-heavy, so do not assume standbys will offload meaningful load without checking which queries, if any, your deployment routes to them.
- Placement: Put standbys on separate hosts or failure domains so one fault does not remove the primary and its standby together.
Confirm the acceptable data loss window and commit latency target with your operations and risk owners before choosing a mode.
PostgreSQL does not detect a failed primary or promote a standby by itself. Replication provides the copy of the data, but the decision to fail over, the promotion step and the redirection of clients all need external tooling and tested procedures. Without that layer, an outage can last until an operator notices and acts. Planning this layer early matters because the failover method affects how Temporal services reconnect, how PgBouncer is configured and how fencing prevents a stale primary from accepting writes.
- Detection and promotion: Choose a failover manager that monitors the primary, promotes a standby and records the event. Confirm it supports your chosen replication mode and your hosting model.
- Client redirection: Decide how Temporal services and PgBouncer find the new primary, whether through a virtual IP, a DNS record or a connection router, and test the switch time.
- Fencing: Ensure the old primary cannot accept writes after promotion, so two primaries do not diverge.
- Backups alongside replication: Replication does not replace point-in-time recovery. Plan continuous archiving and restore tests so you can recover from logical errors that replicate to standbys.
- Failover drills: Run planned failovers in a non-production environment and measure how long Temporal takes to recover, including worker reconnection.
Ask the database owner which failover tool your organization already supports and whether that tool has been tested with the replication mode you select.
The right database layout depends on where Temporal runs and how much downtime the business accepts. A single-node development or evaluation setup, a production cluster inside one data center, and a multi-site or air-gapped deployment each carry different sizing and high availability trade-offs. Temporal's tested PostgreSQL range covers versions 13 to 16, so the version you pick also affects which PostgreSQL release line your platform team must maintain. Treat the environment as a decision that sets the replication, failover and backup scope for the whole project.
- Development and evaluation: Temporal's SQLite support is meant only for development and testing, so use PostgreSQL even for a pilot if the pilot will inform production sizing.
- Single site production: Plan a primary and at least one standby, with a failover tool, PgBouncer and archived backups on separate storage.
- Multi-site production: Decide whether a standby in a second site is synchronous or asynchronous, and confirm the network latency between sites before choosing synchronous mode.
- Air-gapped or restricted networks: Confirm that the failover tooling, monitoring and backup targets are available inside the isolated network.
- Version alignment: Check the supported PostgreSQL range in the Temporal persistence documentation against the release line you plan to run.
Confirm the target environment, the acceptable recovery time and the supported PostgreSQL version with your platform and Temporal teams before you size hardware.
When Cassandra is the better fit than PostgreSQL
For most teams that already run PostgreSQL, PostgreSQL is the simpler persistence choice for self-hosted Temporal. Your staff already know its backup, upgrade, monitoring and access tooling, and the supported range is documented as PostgreSQL 13 to 16 for Temporal persistence, so the database can sit under the same standards your organization already applies. Cassandra is the better fit when the workload is large and write-heavy enough that a relational store becomes the limit, and when your team has or can hire people who operate Cassandra clusters well. Cassandra also brings a separate visibility store requirement, since Cassandra visibility was removed in Temporal Server 1.24, so choosing it adds a second data system to design, back up and monitor.
The decision turns on three questions you should answer before the schema is created. First, what is your expected write volume for workflow history and how steady is it? Estimate this from your planned workflow executions and activities per second, and load test against a realistic profile rather than relying on a general claim. Second, which database skills and on-call coverage do you have today? Third, what do your database standards require, such as approved engines, backup tooling and change control? An organization with an established PostgreSQL platform team usually gains more from reusing it than from a store chosen for a workload it has not yet measured.
Confirm these points with your Temporal and database teams and with the vendor's current support matrix before you commit. The sibling page on Temporal with Apache Cassandra persistence covers the Cassandra schema tool, the separate visibility store and the operational differences in detail. If the answers point to PostgreSQL, the work that follows is sizing, high availability and pooling for that database, not a change of persistence engine.
How Temporal and PostgreSQL concepts map to each other
This table matches each Temporal persistence concept to the PostgreSQL object that holds it, shows which step creates that object, and names the team that owns it. Read it before the schema setup to see which objects the schema tool creates and which ones your team must plan, configure and run.
| Temporal concept | PostgreSQL object | Created by | Owned and configured by |
|---|---|---|---|
| Persistence store | A PostgreSQL database for Temporal state, one for the default store and one for visibility if you use SQL visibility | temporal-sql-tool create-database | Your team names, sizes and provisions the database host and instance |
| Workflow state and metadata | Tables and indexes in the Temporal schema, versioned by the schema tool | temporal-sql-tool setup-schema and update-schema | Schema tool runs setup and upgrades; your team schedules them before server upgrades |
| Namespace | Rows in the namespace tables of the default store | Temporal Server, when you register it through the Temporal CLI or API | Your team chooses names, ownership and retention for each namespace |
| History shard | Rows keyed by shard ID that track ownership and progress for a slice of workflow history | Temporal Server, when it starts against the store | Your team sets the shard count before the first start, since changing it later is a major operation |
| Workflow execution and history | Rows in execution and history tables, keyed by namespace and workflow ID | Temporal Server at runtime | Server writes these rows; your team sizes storage and monitors table growth |
| Task queue tasks and metadata | Rows in task and task queue tables that hold pending work for workers | Temporal Server at runtime | Server manages these rows; your team sets worker counts and monitors backlog |
| Database roles and credentials | PostgreSQL roles with grants on the Temporal databases | Your DBA, before running the schema tool | Your team owns them and should separate schema-change rights from runtime rights |
| Visibility records | Separate visibility database and tables, used only when SQL visibility is configured | Schema tool with the visibility settings | Your team decides whether visibility stays in PostgreSQL or moves to a search store as volume grows |
Securing the PostgreSQL connection and Temporal services
Temporal with PostgreSQL persistence puts the workflow history, visibility data and schema in one database, so its connection and the Temporal services that reach it need controls from the start. The cards below cover database authentication, transport encryption, role separation, secret handling, network placement and API authorization, which the server does not configure for you by default.
Database authentication method
Use SCRAM-based password authentication for the Temporal database roles, and confirm that the pg_hba.conf rules do not allow the older MD5 method. PostgreSQL 18 deprecated MD5 in favor of SCRAM, so a configuration copied from an older guide may still permit it. Where your policy requires it, review certificate authentication or LDAP, both documented by PostgreSQL, and confirm with Temporal's persistence settings which options your server version accepts.
TLS between Temporal and PostgreSQL
Encrypt every connection from the Temporal services to PostgreSQL, and verify the server certificate against your own certificate authority rather than trusting any certificate. Confirm the TLS settings for your Temporal version in the persistence configuration, and check that the hostssl rule is the only one that matches Temporal's source addresses. Unencrypted connections on the database network can expose credentials and workflow payloads.
Least-privilege schema and runtime roles
Create one role that runs the schema tool and migrations, and a separate runtime role for the Temporal services. The runtime role needs data access but not permission to alter or drop tables, so a compromised service cannot change the schema. Restrict the role to the Temporal databases and confirm the exact grants in the schema setup documentation for your release before you apply them.
Secret storage for database passwords
Keep database passwords out of configuration files committed to source control and out of container images. Load them at runtime from a secrets manager or Kubernetes secret that your team already audits, and set rotation and access review as recurring tasks. Confirm which environment variables or file references your chosen deployment method supports, and document who can read the secret store.
Keeping Temporal services off the public internet
The Temporal deployment documentation says the services should run on hosts that the public internet cannot reach, with network access limited to trusted internal networks. Place the frontend, history, matching and worker-facing endpoints on private subnets, and expose only the paths your clients need. Verify the rules from outside your network, because a database that is reachable from the internet defeats the TLS and password controls above.
Temporal deployment docsAPI authorization is a separate setup
If no Authorizer is configured, self-hosted Temporal uses the default noopAuthorizer, which allows every API request with no authentication or access control. Configure mTLS, a ClaimMapper that maps JWT or certificate claims to namespace roles, and an Authorizer plugin before any environment holds real workflows. Signing in to the Web UI with OIDC does not by itself restrict API calls, so test namespace access with a client that has no role.
Temporal security docsCommon PostgreSQL persistence failures and their fixes
This table lists the failures teams most often hit when running self-hosted Temporal on PostgreSQL, with the likely cause and the check or fix for each. Read it as a triage list: match the symptom you see, then work through the cause column before changing configuration.
| Failure | Likely cause | Fix or check to run |
|---|---|---|
| Schema version mismatch after an upgrade | Server binaries were upgraded before the database schema, or a minor version was skipped | Check the schema version against the release notes, run temporal-sql-tool schema updates first, then upgrade the server one minor version at a time |
| Connection exhaustion without pooling | Many history, matching and worker processes each open their own connections to PostgreSQL | Compare total open connections with max_connections, add PgBouncer in front of PostgreSQL, and cap connections per Temporal service |
| Schema setup fails with permission errors | The database user lacks rights to create tables, indexes or extensions, or the wrong database was targeted | Confirm the setup role owns the target database, run setup with a privileged account, then switch the running service to a least-privilege role |
| Stale reads from standbys | Replication lag on a hot standby, or a read path pointed at a standby that is behind the primary | Measure replication lag on each standby, keep Temporal's persistence connections on the primary, and alert when lag grows beyond your recovery target |
| Services still write to the old primary after failover | Connection strings or DNS point at the former primary, and PostgreSQL does not detect failure or repoint clients on its own | Use an external failover manager or virtual endpoint, confirm which node accepts writes, and restart or reconnect Temporal services after the switch |
| Slow history or persistence latency under load | Database undersized for shard traffic, missing autovacuum tuning, or disk I/O limits | Review database CPU, I/O and connection metrics against Temporal service latency, then tune PostgreSQL resources and vacuum settings with the database team |
| Failed restore leaves workflow state inconsistent | Backups taken without a tested point-in-time recovery procedure, or Temporal and visibility stores restored to different times | Restore to a test environment on a schedule, record the restore point for every store, and rehearse recovery with Temporal services stopped |
Questions teams ask before connecting Temporal to PostgreSQL
Who does the PostgreSQL persistence work and what drives the effort?
Usually a platform or database team does the work, with DeployOpen or another partner if you outsource it. The effort is driven by schema setup with temporal-sql-tool, sizing the database for your workflow history and shard traffic, designing high availability for the database, testing failover and restore, and planning how schema and server upgrades run over time. Each of these adds work in proportion to how many environments you run and how strict your change controls are. Ask any partner for a written scope that lists these items separately so you can compare quotes on the same basis.
Can an internal team set up Temporal on PostgreSQL alone?
Yes, if the team already runs PostgreSQL in production and has experience with Kubernetes or a comparable deployment method for the Temporal Server services. The steps are documented, but the hard parts are judgment calls: sizing, failover design, and how database maintenance windows line up with Temporal upgrades. Teams without recent PostgreSQL operations experience usually benefit from an outside review of the design before go-live. Check the supported PostgreSQL versions and the Temporal release you plan to run against the official persistence documentation before you start.
How long does the work take?
The duration depends on the number of environments, whether high availability is in scope, how much load testing you need, and whether you already have PostgreSQL operations in place. Work that covers a single non-production environment is much shorter than a production design with replicas, backups and tested recovery. Ask for a timeline in the written scope with milestones for design, build, testing and handover. Be cautious of any timeline quoted before your environment and requirements are reviewed.
What does the work need from our team?
Expect to provide database administrator access or a dedicated account for schema setup, and network changes that let Temporal services reach PostgreSQL on the required ports. You will also need test workloads that resemble your expected workflow volume, and change windows for schema changes, failover tests and restore drills. The Temporal deployment documentation says services should run on hosts not reachable from the public internet, so confirm that your network design allows this. Agree on who approves each change before the work starts.
Do PostgreSQL upgrades affect Temporal upgrades?
They can, because both sit on the same data path and both need careful sequencing. PostgreSQL minor releases do not change the internal storage format, so they mainly require replacing executables and restarting. Major PostgreSQL upgrades need a supported method such as pg_upgrade or logical replication, and you must confirm that the Temporal release you run is tested on the target PostgreSQL major version. Temporal requires one minor version at a time and says schema upgrades must run before server upgrades when release notes call for them. Plan the two upgrade tracks together so they never overlap in the same window.
When should we choose Temporal Cloud instead of PostgreSQL persistence?
Choose Temporal Cloud when your team does not want to operate the database, the Temporal Server and the high availability design, and when the managed service's terms and data location fit your compliance needs. Self-hosting suits organizations that must keep workflow data in infrastructure they control. Temporal Cloud pay-as-you-go pricing starts at 50 US dollars per million actions, with active storage at 0.042 dollars per GB-hour and retained storage at 0.00105 dollars per GB-hour, according to Temporal's pricing page. Support tiers add cost, and the Enterprise and Mission Critical tiers are quoted by sales. Compare these figures with the full cost of running your own database, servers and on-call rota.
Is Cassandra a better fit than PostgreSQL for our workload?
PostgreSQL is simpler for most teams that already operate it, while Cassandra is the option to evaluate for very large, write-heavy workloads that your PostgreSQL design cannot handle. The decision depends on your expected throughput, your team's operating experience, and whether you can run a separate visibility store, which Cassandra requires since Temporal Server 1.24. Advanced visibility is recommended on Elasticsearch or OpenSearch for anything beyond a few workflow executions. Load test both options against realistic volumes before you commit.
How DeployOpen scopes and delivers Temporal PostgreSQL work
DeployOpen starts every Temporal PostgreSQL engagement with a written fixed scope agreed before work begins. The scope names the Temporal Server version and its target minor line, the PostgreSQL major version, the deployment method (Helm chart, Docker Compose, binaries or a custom Go build), the number of Temporal Server services and the regions or clusters involved. Before any build, the team reviews the target versions against the supported lists in the persistence and upgrade documentation, and confirms that the Helm chart version matches the server image. Sizing inputs such as expected workflow execution volume, history size, retention period and visibility requirements are collected and recorded so that the database sizing and the hardware or cloud instance choices can be traced back to them. Any sizing figure a client expects to be stated in the quote should come from their own load profile, and the quote should say which inputs it depends on.
Delivery follows a planned sequence in the client's own accounts, data centers or air-gapped networks. The schema is created with temporal-sql-tool before the Temporal Server is started, and the database role, connection settings and TLS for the PostgreSQL connection are reviewed against the client's security baseline. High availability and backup design is documented as a decision record: whether the database uses streaming replication with synchronous or asynchronous commit, how failover is detected and performed because PostgreSQL does not provide that detection itself, whether a connection pooler such as PgBouncer is placed in front of the database, and how continuous archiving and point-in-time recovery are configured and proven. Testing covers a failover drill, a restore into a separate environment, a Temporal Server upgrade rehearsal that applies schema changes before server changes, and an assessment of the network placement of Temporal services, which should not be reachable from the public internet. Operators receive written runbooks, a configuration inventory and a record of the test results.
Ownership and cost are set by the scope. The one-time parts are design, schema setup, the failover and restore tests and documentation, and their size depends on how many environments, regions and database clusters are in scope. Recurring parts belong to the client team or to an optional retainer for support, PostgreSQL minor updates, Temporal patch releases and periodic restore tests. DeployOpen prepares systems, configurations and evidence that a client's compliance or security team can review, but it does not issue audit reports, attestations or certifications. Independent auditors and certification bodies make those determinations. Clients should ask any quote to list the environments included, the test cases, the handover materials and what is excluded, such as application workflow code, which belongs to the client's development team.

