OLAP Template
olap.yml is optimized for online analytical processing (OLAP). Designed for 4-128 core CPUs with support for large queries, high parallelism, relaxed timeouts, and aggressive vacuum.
Pair with
node_tune=olapfor OS-level tuning.
Use Cases
OLAP template is ideal for:
- Data warehouses: Historical data storage, multidimensional analysis
- BI reports: Complex report queries, dashboard data sources
- ETL processing: Data extraction, transformation, loading
- Data analysis: Ad-hoc queries, data exploration
- HTAP mixed workloads: Analytical replicas
Workload characteristics:
- Complex queries (seconds to minutes)
- Low concurrent connections (tens to hundreds)
- Read-intensive, writes typically batch operations
- Throughput-sensitive, tolerates higher latency
- Scans large data volumes
Usage
Specify pg_conf = olap.yml in cluster definition:
Use olap.yml template for dedicated offline replicas:
Parameter Details
Connection Management
OLAP scenarios typically don’t need many connections; 500 is sufficient for most analytical workloads.
Memory Config
OLAP template uses more aggressive memory allocation:
| Parameter | Formula | Description |
|---|---|---|
shared_buffers |
mem × pg_shared_buffer_ratio |
Default ratio 0.25 |
maintenance_work_mem |
shared_buffers × 50% | Faster index creation and VACUUM |
work_mem |
64MB - 8GB | Larger sort/hash memory |
effective_cache_size |
total mem - shared_buffers | Estimated cache memory |
work_mem calculation (differs from OLTP):
Larger work_mem allows bigger sort and hash operations in memory, avoiding disk spill.
Locks & Transactions
OLAP queries may involve more tables (partitions, many JOINs), requiring more lock slots.
Parallel Query
OLAP template aggressively enables parallel queries:
Parallel cost estimates use defaults to favor parallel plans:
Partition-wise optimization enabled:
IO Config (PG18)
More IO workers support parallel large table scans.
WAL Config
Larger temp_file_limit allows bigger intermediate results to spill to disk.
Vacuum Config
OLAP template uses aggressive vacuum settings:
Analytical databases often have bulk writes requiring aggressive vacuum to reclaim space.
Query Optimization
Higher default_statistics_target provides more accurate query plans, crucial for complex analytics.
Logging & Monitoring
Client Timeouts
Analytical queries may need to hold transactions for extended periods, so idle timeout is disabled.
Key Differences from OLTP
| Parameter | OLAP | OLTP | Reason |
|---|---|---|---|
| max_connections | 500 | 500-1000 | Fewer analytical connections |
| work_mem limit | 8GB | 1GB | Support larger in-memory sorts |
| maintenance_work_mem | 50% buffer | 25% buffer | Faster index creation |
| max_locks_per_transaction | 2-4x | 1-2x | More tables in queries |
| max_parallel_workers | 80% cpu | 50% cpu | Aggressive parallelism |
| max_parallel_workers_per_gather | 50% cpu | 20% cpu | Aggressive parallelism |
| parallel_setup_cost | 1000 | 2000 | Default, encourages parallel |
| parallel_tuple_cost | 0.1 | 0.2 | Default, encourages parallel |
| enable_partitionwise_join | on | off | Partition optimization |
| enable_partitionwise_aggregate | on | off | Partition optimization |
| vacuum_cost_delay | 10ms | 20ms | Aggressive vacuum |
| vacuum_cost_limit | 10000 | 2000 | Aggressive vacuum |
| temp_file_limit | 1/5 disk | 1/20 disk | Allow larger temp files |
| io_workers | 50% cpu | 25% cpu | More parallel IO |
| log_min_duration_statement | 1000ms | 100ms | Relaxed slow query threshold |
| default_statistics_target | 1000 | 400 | More precise stats |
| idle_in_transaction_session_timeout | Disabled | 10min | Allow long transactions |
Performance Tuning Tips
With TimescaleDB
OLAP template works great with TimescaleDB:
With pg_duckdb
For ultimate analytical performance, combine with pg_duckdb:
Columnar Storage
Consider columnar storage extensions:
Resource Isolation
For mixed workloads, isolate analytics to dedicated replicas:
Monitoring Metrics
Focus on these metrics:
- Query time: Long query execution time distribution
- Parallelism: Parallel worker utilization
- Temp files: Temp file size and count
- Disk IO: Sequential and index scan IO volume
- Cache hit ratio: shared_buffers and OS cache hit rates
References
pg_conf: PostgreSQL config template selectionnode_tune: OS tuning template, should matchpg_conf- OLTP Template: Transaction template comparison
- CRIT Template: Critical business template comparison
- TINY Template: Micro instance template comparison
- Offline Replica: Dedicated analytics instances