RAG? or Text To SQL
Source: Dev.to
Background
I recently worked on a project involving a relatively small database: 16 columns and 20,001 rows containing company addresses and status details. The task was to fetch data based on user queries while guaranteeing zero hallucination. The system also needed to support aggregate functions such as calculating maximums and averages. Because the chatbot was a proof‑of‑concept, the database size was intentionally kept modest.
Approach
Given the requirements, I chose a Text‑to‑SQL architecture. This approach offers higher deterministic accuracy than Retrieval‑Augmented Generation (RAG) and can natively perform operations like AVG, MAX, and other aggregations—core functionalities needed for the chatbot.
Considerations
- Concurrency: The expected load is up to 100 concurrent users.
- Scalability: The database supports horizontal scaling without the computational overhead of re‑indexing vectors.
- Data volatility: Certain columns (e.g.,
capital) may change frequently, making a deterministic Text‑to‑SQL solution more efficient for this type of dataset.