π§ Your Database Is Already a Vector Database
Most RAG tutorials start the same way: "First, spin up a vector database."
But Stop.
If you're on Rails, you already have PostgreSQL.
With the pgvector extension it can store and search embeddings and for most applications, that's the whole answer.
π Setup is one migration
`enable_extension "vector"
add_column :document_chunks, :embedding, :vector, limit: 1536`
π And one line in your model
Gemfile
gem "neighbor"
class DocumentChunk < ApplicationRecord
has_neighbors :embedding, dimensions: 1536, normalize: true
end
π Searching is just ActiveRecord
DocumentChunk
.where(tenant: Current.tenant)
.nearest_neighbors(:embedding, query_vector, distance: "cosine")
.limit(6)
Scoped, chainable, joinable. A normal Rails query.
π Why this beats a separate vector DB
1οΈβ£ No new infrastructure
Nothing extra to deploy, monitor, back up, or upgrade.
2οΈβ£ Transactional consistency
Embeddings commit in the same transaction as the record.β¦