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)
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
- Basic
- With TLS
- Separate Visibility DB
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
Schema Tables
Key Cassandra tables created:executions- Workflow execution state and historynamespaces- Namespace metadataqueue- Task queue informationcluster_metadata- Cluster configurationtasks- 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
- Docker
- Docker Compose
- Production Cluster
Elasticsearch Configuration
- Basic
- With Authentication
- Dual Visibility
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)
Configuration
Database Schema Reference
Persistence Store Tables
- Core Tables
- Task Tables
- History Tables
namespaces
- Stores namespace metadata
- Contains retention policies and archival settings
- One row per history shard
- Stores shard ownership and range IDs
- Workflow execution state and mutable data
- Activity and timer states
- 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
- User-defined search attribute definitions
Connection Pool Tuning
Calculating Pool Sizes
For SQL databases:Performance Tuning
- High Throughput
- Resource Constrained
- Balanced
Database Maintenance
Backup Strategies
MySQL Backup
MySQL Backup
PostgreSQL Backup
PostgreSQL Backup
Cassandra Backup
Cassandra Backup
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
Schema version mismatch
Schema version mismatch
Error: “schema version mismatch”Solution:
Too many connections
Too many connections
Error: “Too many connections” or connection pool exhaustedSolutions:
- Reduce
maxConnsin configuration - Increase database
max_connections - Scale down number of service instances
- Check for connection leaks
Slow queries
Slow queries
Symptoms: High query latency, timeoutsSolutions:
- Enable slow query log
- Check database indexes
- Analyze query execution plans
- Consider read replicas for visibility queries
- Tune database parameters (buffer pool, cache)