Embeddings are used in many modern AI applications.
They can power:
- Semantic search
- Recommendations
- RAG
- Document matching
- AI assistants
But generating embeddings is only part of the problem.
You also need somewhere to store them.
What Is an Embedding?
An embedding is a numerical representation of data.
For text:
"How do I deploy my website?"
↓
Embedding Model
↓
Vector
The vector can then be compared with other vectors.
Why Store Embeddings in PostgreSQL?
If your application already uses Supabase PostgreSQL, storing embeddings in the same database can simplify the architecture.
Instead of:
Database
+
Vector Database
+
Synchronization
you can potentially keep application records and vectors together.
Example Table
A document table might contain:
documents
id
title
content
embedding
created_at
The embedding belongs to the document it represents.
Store Metadata
Do not store only the vector.
Useful metadata includes:
- Document ID
- Title
- Category
- User ID
- Source
- Created date
This allows your application to filter results.
Generate Embeddings Outside the Database
The embedding model usually runs outside PostgreSQL.
The workflow can look like:
Text
↓
Embedding API
↓
Vector
↓
Supabase PostgreSQL
Keep the AI provider's private API key on the server.
Searching Embeddings
When a user searches, generate another embedding for the query.
Then compare the query vector with stored vectors.
Query Vector
↓
Similarity Search
↓
Closest Documents
Indexing Matters
Vector datasets can become large.
As your application grows, appropriate indexing can improve search performance.
The exact indexing strategy depends on:
- Dataset size
- Vector dimensions
- Query volume
- Accuracy requirements
Keep Embedding Versions
AI models can change.
A useful practice is storing information about which embedding model generated each vector.
For example:
embedding_model
embedding_version
If you later change models, you can regenerate embeddings systematically.
Protect User Data
If embeddings represent private documents, they are still application data.
Use appropriate authentication and authorization.
Do not assume that storing the vector instead of the original text makes the information automatically public or harmless.
Final Thoughts
Embeddings are a data problem as much as an AI problem.
A good database structure should store the vector alongside enough metadata to identify, filter and manage it.
For applications already built around Supabase PostgreSQL, vector storage can provide a convenient foundation for AI search and recommendation features.