Storage Architecture
Mastra’s storage system is built around composable adapters:Quick Start
Configure storage in your Mastra instance:Storage Domains
Mastra storage is organized into domains:Memory
Store conversation threads and messages:Workflows
Persist workflow runs and state:Agents
Store agent configurations and state:Observability
Track tool calls, events, and metrics:Scores
Store evaluation scores and metrics:Pluggable Backends
Swap storage backends without changing application code:Composite Storage
Mix and match backends for different domains:Schema Management
Most SQL adapters provide schema export utilities:Vector Storage
Vector stores are used for semantic search and RAG:Storage Configuration
Common configuration patterns:Connection Pooling
Schema Namespacing
Read Replicas
Transaction Support
Some adapters support transactions:Error Handling
Handle storage errors gracefully:Performance Considerations
Connection Pooling
Connection Pooling
Use connection pooling for SQL databases to reuse connections and improve performance
Indexing
Indexing
Create indexes on frequently queried fields like threadId, workflowId, and timestamps
Batching
Batching
Batch multiple operations when possible to reduce round trips
Caching
Caching
Consider adding a cache layer (Redis, Upstash) for hot data paths
Migration Between Adapters
Switch storage backends:Next Steps
Storage Adapters
Explore available storage backends
Vector Stores
Learn about vector storage for RAG