🏗️ Infrastructure#vector-db#rag#tutorial
Vector database là gì và khi nào bạn thật sự cần nó?
Embedding search nghe rất mạnh, nhưng không phải project nào cũng cần vector DB từ ngày đầu.
By K3 Admin·8 phút đọc·2 views·31/3/2026
Vector DB giải quyết vấn đề gì?
Traditional search: keyword matching (LIKE '%query%')
Vector search: semantic matching (ý nghĩa tương tự)
Ví dụ: search "cách nấu phở" → vector search cũng trả về "recipe for Vietnamese beef noodle soup"
Cách hoạt động
- Text → Embedding model → Vector (array of 768-3072 numbers)
- Vectors lưu vào specialized database
- Query → embed → find nearest vectors (cosine similarity)
- RAG system (search internal docs)
- Semantic search (product search, FAQ matching)
- Recommendation (similar items/content)
- Anomaly detection (find outliers in data)
- Data < 10K documents → pgvector đủ
- Only keyword search needed → PostgreSQL full-text
- Real-time updates critical → vector DBs have indexing lag
- Budget tight → managed vector DB = expensive
Khi nào CẦN vector DB?
Khi nào KHÔNG cần?
Options
| DB | Type | Best for |
|----|------|----------|
| pgvector | Extension | Already use PostgreSQL, small-medium data |
| Pinecone | Managed | Production, don't want to manage infra |
| Qdrant | Self-hosted | Full control, good performance |
| Weaviate | Self-hosted | GraphQL API, hybrid search |
| ChromaDB | Embedded | Prototyping, small projects |