Indexing Notes
Recommended database indexes for Elsa Workflows persistence stores to optimize common query patterns.
Overview
Key Query Patterns
Query Pattern
Tables Involved
Index Recommendation
PostgreSQL Indexes
Workflow Instances
-- Primary lookup by ID (usually covered by PK)
-- CREATE INDEX idx_workflow_instances_id ON workflow_instances(id);
-- Query by correlation ID (very common for HTTP workflows)
CREATE INDEX idx_workflow_instances_correlation_id
ON workflow_instances(correlation_id)
WHERE correlation_id IS NOT NULL;
-- Query by status (list pending, running, faulted, etc.)
CREATE INDEX idx_workflow_instances_status
ON workflow_instances(status);
-- Query by definition (list all instances of a workflow)
CREATE INDEX idx_workflow_instances_definition_id
ON workflow_instances(definition_id);
-- Composite for filtered status queries
CREATE INDEX idx_workflow_instances_status_definition
ON workflow_instances(status, definition_id);
-- Retention queries (cleanup by age)
CREATE INDEX idx_workflow_instances_updated_at
ON workflow_instances(updated_at DESC);
CREATE INDEX idx_workflow_instances_finished_at
ON workflow_instances(finished_at)
WHERE finished_at IS NOT NULL;
-- List by sub-status (more granular than status)
CREATE INDEX idx_workflow_instances_sub_status
ON workflow_instances(sub_status);Bookmarks
Activity Execution Records
Workflow Execution Logs
Incidents
Workflow Inbox Messages
SQL Server Indexes
MongoDB Indexes
Index Maintenance
PostgreSQL
SQL Server
MongoDB
Performance Monitoring
Identifying Missing Indexes
Best Practices
Vendor Documentation
Related Documentation
Last updated