When we first built the prototype for Opintell, we did what most AI engineers do: we used **FAISS (Facebook AI Similarity Search)**. It was fast, simple to set up, and ran efficiently in a local Jupyter notebook.
However, once we moved to a containerized multi-tenant cloud environment on Docker and Render, local file-based vector indices became our single biggest architectural bottleneck.
The Three Fatal Bottlenecks of Local FAISS Files
FAISS stores vector indices as discrete binary files on disk (`./data/faiss_indices`). In a cloud environment where API workers scale horizontally or restart during deployments, keeping local files synchronized across instances was nearly impossible without complex file-sync sidecars.
When a user deleted an organization or removed an outdated machinery manual, we had to delete the record in PostgreSQL and then separately modify the FAISS binary index. If the server crashed mid-operation, the vector index fell out of sync with the database, leading to orphaned vectors and corrupted citation lookups.
In multi-tenant industrial systems, permissions matter. A Junior Operator in Plant A should never retrieve document chunks belonging to Plant B. With FAISS, filtering required pulling raw IDs from FAISS and then querying SQL to check permissions — creating massive latency spikes.
The Solution: Migrating to PostgreSQL with pgvector
To solve this, we migrated entirely to **PostgreSQL with the `pgvector` extension**.
By storing vector embeddings directly as a native column type (`vector(768)`) alongside our relational tables (`documents`, `document_chunks`, `organizations`), we achieved significant architectural advantages:
- Single Query Multi-Tenancy: We can filter by `organization_id`, check user RBAC roles, and calculate cosine similarity in a single atomic SQL query.
- Automated Backups & Disaster Recovery: Vector embeddings are backed up alongside relational state with automated daily snapshots.
- Zero Synchronization Drift: When a document is deleted, standard PostgreSQL cascading foreign keys remove all associated chunks and vector embeddings instantaneously.
The migration reduced our deployment complexity by 70% and enabled sub-380ms end-to-end retrieval across millions of indexed technical manual chunks.
Naveen M
Founder & Engineering Lead
Building deterministic knowledge systems and RAG architectures for Industry 4.0 manufacturing facilities.