Skip to main content
Temporal Server requires two types of databases: a persistence store for workflow execution state and a visibility store for workflow search and listing. This guide covers setup for all supported databases.

Database Requirements

Persistence Store

Stores workflow execution history, state, and metadataSupported:
  • Cassandra 3.11+
  • MySQL 8.0+
  • PostgreSQL 12+
  • SQLite (development only)

Visibility Store

Enables workflow search and filteringSupported:
  • MySQL 8.0+ (standard)
  • PostgreSQL 12+ (standard)
  • Elasticsearch 7.10+ (advanced)
Important: You cannot change the number of history shards after initial deployment. Choose an appropriate value based on your expected workload.

MySQL Setup

Prerequisites

  • MySQL 8.0.29 or higher
  • Sufficient privileges to create databases and users
  • Network connectivity from Temporal servers

Database Creation

1

Create databases

2

Create user and grant permissions

3

Download or build temporal-sql-tool

4

Initialize schema for persistence store

5

Initialize schema for visibility store

Using Custom Schema Directory

If you need to apply schema from a local directory:

Schema Upgrade

To upgrade to a specific version:

MySQL Configuration Options

PostgreSQL Setup

Prerequisites

  • PostgreSQL 12 or higher
  • Sufficient privileges to create databases and users

Database Creation

1

Create databases

2

Create user and grant permissions

3

Initialize schema for persistence store

4

Initialize schema for visibility store

PostgreSQL Configuration

Use postgres12_pgx instead of postgres12 for better performance with the pgx driver.

Cassandra Setup

Prerequisites

  • Cassandra 3.11 or higher
  • Replication factor of 3 recommended for production

Keyspace Creation

1

Build temporal-cassandra-tool

2

Create keyspace

3

Initialize schema

Cassandra Configuration

Cassandra is not supported for visibility stores. You must use MySQL, PostgreSQL, or Elasticsearch for visibility.

Schema Tables

Key Cassandra tables created:
  • executions - Workflow execution state and history
  • namespaces - Namespace metadata
  • queue - Task queue information
  • cluster_metadata - Cluster configuration
  • tasks - Transfer, timer, and replication tasks

Elasticsearch Setup

Elasticsearch provides advanced visibility features including full-text search and custom search attributes.

Prerequisites

  • Elasticsearch 7.10+ or 8.x
  • At least 2GB heap size recommended

Installation

Elasticsearch Configuration

Index Templates

Temporal automatically creates index templates on startup. No manual index creation is required.
Elasticsearch indices are automatically created with appropriate mappings when Temporal Server starts.

SQLite Setup (Development Only)

SQLite is only for local development. Never use in production.

Configuration

Database Schema Reference

Persistence Store Tables

namespaces
  • Stores namespace metadata
  • Contains retention policies and archival settings
shards
  • One row per history shard
  • Stores shard ownership and range IDs
executions
  • Workflow execution state and mutable data
  • Activity and timer states
current_executions
  • Current/latest execution for each workflow ID
  • Used for uniqueness constraints

Visibility Store Tables

executions
  • Workflow execution metadata for search
  • Custom search attributes
  • Start/close time, status, workflow type
custom_search_attributes
  • User-defined search attribute definitions

Connection Pool Tuning

Calculating Pool Sizes

For SQL databases:

Performance Tuning

Database Maintenance

Backup Strategies

Monitoring

Key metrics to monitor:
  • Connection Pool: Active connections, idle connections, wait time
  • Query Latency: P50, P95, P99 for reads and writes
  • Error Rate: Connection errors, query failures
  • Disk Usage: Database size, growth rate
  • Replication Lag: For replicated setups

Troubleshooting

Error: “schema version mismatch”Solution:
Error: “Too many connections” or connection pool exhaustedSolutions:
  1. Reduce maxConns in configuration
  2. Increase database max_connections
  3. Scale down number of service instances
  4. Check for connection leaks
Symptoms: High query latency, timeoutsSolutions:
  1. Enable slow query log
  2. Check database indexes
  3. Analyze query execution plans
  4. Consider read replicas for visibility queries
  5. Tune database parameters (buffer pool, cache)