# Long context, search or SQL: which should answer a business question?

Choose long context, retrieval or SQL for the question at hand. Compare document explanations, exact totals and mixed questions with a practical framework.

By Daltn editorial team. Published 2026-11-01.
Canonical: https://daltn.tech/feeds/rag-long-context-business-records/

## When should a business question use long context, retrieval or SQL?

Long context, retrieval and SQL answer different parts of a business question and can work together. Long context supplies more material, retrieval finds relevant passages, and SQL filters or calculates over defined records. Match the method to the question, inspect its evidence and test the final answer against accepted facts and realistic exceptions.

## Keep these in mind

- Use exact record queries for totals with a defined scope.
- Use search for relevant evidence and long context for useful surrounding material.
- Show freshness, filters and missing information in the answer.

## Start by classifying the question

“What did we promise Rahul?” may need messages, a quote and an accepted order. “How much is outstanding on approved invoices?”

needs a defined set of records and a calculation. Both are business questions, but their evidence paths differ.

Retrieval-augmented generation, or RAG, searches a knowledge base and supplies relevant material to the model. It can help explain a document-based answer.

A structured query can identify all records matching a precise condition. Neither should be used blindly for every task.

## Large input capacity is useful, with limits

The 2023 [Lost in the Middle study](https://arxiv.org/abs/2307.03172) tested multi-document questions and key-value retrieval. Results varied with information position in the models studied. It is evidence about those tasks and models, not a universal score for current systems.

A long-context model may perform well for your document set. Test it.

Place a crucial detail in different positions, include a later correction and ask about an unfamiliar identifier. Context capacity tells you how much can fit, while evaluation tells you whether the needed evidence is used correctly.

## Route questions to suitable evidence

The following table suggests evidence routes for common business questions. Use it to specify a trial and compare the answer with the records that should support it.

Question | Primary route | Check before answering
--- | --- | ---
“Find quote Q-104” | Exact identifier lookup | Correct tenant and version
“What changed in the agreement?” | Retrieve and compare documents | Use the latest accepted versions
“Total approved dues this month?” | Structured filter and calculation | Define dates, status and currency
“Why is this delivery late?” | Linked records and source excerpts | Separate observed facts from inference
“Explain the customer history” | Relevant context and summaries | Include recent corrections and gaps

## Exact matching and meaning-based search complement each other

A product code may differ by a single character. Meaning-based similarity can find related text but may retrieve the wrong code.

[Anthropic’s contextual-retrieval research](https://www.anthropic.com/research/contextual-retrieval) discusses combining retrieval methods and retaining context around chunks. This supports testing several evidence paths, not declaring one universally superior.

For an identifier question, check the identifier directly. For a broad topic, semantic search can find related language.

Permission filtering should happen before retrieved content reaches the model. An elegant explanation based on an unauthorized document is still an unacceptable answer.

## A total needs a definition

A question about this month’s money may mean received payments, invoice value or expected cash. Ask which measure is intended. [PostgreSQL’s table-expression documentation](https://www.postgresql.org/docs/current/queries-table-expressions.html) explains filtering and grouping over tables; the business must still define the right rows.

For a fictional example, two accepted invoice records are ₹12,000 and ₹8,000, while a draft is ₹5,000. An “approved invoice value” total is ₹20,000 under those stated rules.

It is not ₹25,000, and it is not proof of cash received. Display the scope beside the number.

## Evaluate answers with evidence and corrections

Build a test set containing exact lookups, calculated questions and explanations. Include two customers with the same name, a deleted document, a revised amount and records outside the user’s access. Check the answer, its sources and what the system says when evidence is incomplete.

Evaluate a proposed assistant through specific questions about representative business records. Check the answer and its supporting sources, then correct a source record and ask again. Include a restricted user in the trial to check the permission boundary.

Explain the date range, included records and important gaps. Another person can then judge what the answer means.

1. Identify whether the question needs lookup, calculation or explanation.
1. Define relevant records, dates and permissions.
1. Retrieve the appropriate evidence and calculate where needed.
1. Show the scope, sources and missing context.
1. Recheck answers after corrections or source changes.

## Common questions

### When should an AI answer use a structured query?

Use a defined query for accepted records, such as approved invoice totals within a date range. Confirm the meaning of the measure, currency and permissions. Let the explanation show the scope and any missing information.

### When is document retrieval useful?

Retrieval helps locate relevant passages and surrounding evidence for an explanation. Test exact identifiers, later corrections and incomplete sources. Full-document context, search and structured queries can complement each other; evaluate the final answer for the actual task.

## Sources

- [Lost in the Middle: How Language Models Use Long Contexts](https://arxiv.org/abs/2307.03172): Provides historical research on positional effects in specific long-context tasks.
- [Introducing Contextual Retrieval](https://www.anthropic.com/research/contextual-retrieval): Discusses retrieval design and preserving document context.
- [PostgreSQL Table Expressions](https://www.postgresql.org/docs/current/queries-table-expressions.html): Documents filtering, joining and grouping structured data.
