How to retrieve relevant columns from 100+-column tables in a Text-to-SQL agent
Beginning_Letter3742 · reddit · 2026-11-27
A developer building a Text-to-SQL agent for executives describes the column-selection challenge: some tables have 100+ columns, and since they can't predict every possible question, they can't permanently exclude any column—yet passing all columns bloats context and adds noise.
Proposed approach: semantic column retrieval
- Maintain a YAML metadata file per table with column name, type, business description, synonyms, and foreign keys
- Embed column descriptions and synonyms; on each question, run similarity search against the selected tables' columns
- Pass only the retrieved schema to the LLM for SQL generation
Open concerns
- Is maintaining descriptions/synonyms for every column in 100–200+ column tables worth the effort?
- Pure semantic similarity may miss indirectly relevant columns and columns needed for joins, filters, or aggregations
- Should they use hybrid retrieval (keyword + semantic), schema linking, or multi-stage retrieval?
- They ask for production-grade Text-to-SQL architectures and papers worth studying
More from coding & agent
- Auditing Claude with a second model: interim report cites six patterns of obstruction — Yamapama · 2026-11-29
- Bitts launches on Bittensor: decentralized AI agent team wired into 15+ subnets — markjeffrey · 2026-11-29
- Anthropic responds to the sabotage debate: model mistakes, not sabotage — trust is a workflow — McDonaghMatthew · 2026-11-29
- Pick AI tools by finding your bottleneck, not by chasing the newest model — brandongalang · 2026-11-29
- Dev uses Codex to clone Obsidian's UX with high fidelity, passing 24/24 acceptance tests — burkov · 2026-11-29
- Dev vibecodes a PS1-style dark fantasy browser game over breakfast, open-sources it — XRarchitect · 2026-11-29