---
name: mastra-pg
description: Documentation for @mastra/pg. Use when working with @mastra/pg APIs, configuration, or implementation.
metadata:
  package: "@mastra/pg"
  version: "1.25.0"
---

## When to use

Use this skill whenever you are working with @mastra/pg to obtain the domain-specific knowledge.

## How to use

Read the individual reference documents for detailed explanations and code examples.

### Docs

- [Workers](references/docs-deployment-workers.md) - Run Mastra workflow orchestration, schedules, and long-running background tasks in dedicated workers to keep API processes responsive under load.
- [Semantic recall](references/docs-memory-semantic-recall.md) - Retrieve relevant messages from past Mastra conversations with semantic recall, vector search, embeddings, metadata filters, and configurable storage.
- [Working memory](references/docs-memory-working-memory.md) - Persist user profiles, preferences, and application data with Mastra working memory using resource- or thread-scoped templates and storage adapters.
- [Storage](references/docs-storage.md) - Configure Mastra storage to persist memory, workflow state, observability data, evals, schedules, and long-running agent state across restarts.

### Integrations

- [DynamoDB](references/integrations-databases-dynamodb.md) - Persist Mastra data in Amazon DynamoDB with a single-table ElectroDB design, configurable indexes, TTL support, credentials, and table initialization.
- [Neon Postgres](references/integrations-databases-neon.md) - Connect Mastra to Neon Postgres with PostgresStore, pooled production connections, schema initialization, vector search, and Neon agent skills.
- [PostgreSQL](references/integrations-databases-postgresql.md) - Persist Mastra application data in PostgreSQL with PostgresStore, configure connections and pools, initialize schemas, and enable observability.

### Reference

- [Reference: Memory class](references/reference-memory-memory-class.md) - The Memory class provides a reliable system for managing conversation history and thread-based message storage in Mastra.
- [Reference: MessageHistory](references/reference-processors-message-history-processor.md) - The MessageHistory is a hybrid processor that handles both retrieval and persistence of message history.
- [Reference: SemanticRecall](references/reference-processors-semantic-recall-processor.md) - The SemanticRecall is a hybrid processor that enables semantic search over conversation history using vector embeddings.
- [Reference: WorkingMemory](references/reference-processors-working-memory-processor.md) - The WorkingMemory is an input processor that injects working memory data as a system message.
- [Chunking and embedding documents](references/reference-rag-chunking-and-embedding.md) - Chunk documents with MDocument, generate embeddings through the AI SDK, and prepare text and metadata for vector storage and RAG retrieval.
- [Reference: Metadata filters](references/reference-rag-metadata-filters.md) - Mastra provides a unified metadata filtering syntax across all vector stores, based on MongoDB/Sift query syntax.
- [RAG (Retrieval-Augmented Generation) in Mastra](references/reference-rag-overview.md) - RAG in Mastra helps you enhance LLM outputs by incorporating relevant context from your own data sources, improving accuracy and grounding responses in real information.
- [Retrieval, semantic search, reranking](references/reference-rag-retrieval.md) - After storing embeddings, you need to retrieve relevant chunks to answer user queries.
- [Storing embeddings in a vector database](references/reference-rag-vector-databases.md) - After generating embeddings, you need to store them in a database that supports vector similarity search.
- [Reference: Composite storage](references/reference-storage-composite.md) - MastraCompositeStore can compose storage domains from different providers. Use it when you need different databases for different purposes.
- [Reference: Storage retention (prune)](references/reference-storage-retention.md) - prune() deletes rows. It caps growth and is safe to run against large tables (batched, bounded, resumable, cancellable).
- [Reference: createVectorQueryTool()](references/reference-tools-vector-query-tool.md) - The createVectorQueryTool() function creates a tool for semantic search over vector stores.
- [Reference: PG vector store](references/reference-vectors-pg.md) - The PgVector class provides vector search using PostgreSQL with pgvector extension. It provides reliable vector similarity search capabilities within your existing PostgreSQL database.


Read [assets/SOURCE_MAP.json](assets/SOURCE_MAP.json) for source code references.