
On this page
- How much does a single LLM call actually cost?
- Why does an LLM call feel free until it isn’t?
- What does a SQL query cost next to that?
- Why does the latency gap matter as much as the cost?
- How does LLM latency compound in an agent loop?
- So when should a question go to the model instead of the database?
- Questions people ask
Picture a design review. A team has data sitting in Postgres, a question it could answer with a WHERE clause, and someone suggests sending it to a language model instead. The query would run against an index on a database the team already pays for. The model call is billed per token and writes its answer one token at a time.
The reflex is understandable. LLMs feel free in development, where you’re making ten calls a day and the invoice rounds to nothing. So the cost question can go unasked until the feature ships, traffic arrives, and someone asks why the inference line grew faster than the user count.
An LLM call and a SQL query aren’t interchangeable tools with slightly different price tags. They’re priced on different models and spend their time in different ways, and most of the time that gap should decide which one you reach for. Here’s the arithmetic on both sides, and the places where the model earns its cost.
How much does a single LLM call actually cost?
It depends on the model and the tokens. At October 2026 list prices, a call of 1,000 input and 500 output tokens costs about a cent on a mid-priced model and a tenth of that on a budget one, and a long reasoning answer can pass a dollar. Which tier you call moves the price of one answer by more than a hundredfold.
Here’s the arithmetic, using rates listed on OpenAI’s API pricing page and Google’s Gemini API pricing page in October 2026, for an assumed call of 1,000 input tokens and 500 output tokens:
OpenAI gpt-5.4 (mid-priced) $2.50 per 1M input tokens, $15.00 per 1M output tokens
input 1,000 x $2.50 / 1M = $0.0025
output 500 x $15.00 / 1M = $0.0075
per call = $0.0100 (a cent)
Gemini 3.1 Flash-Lite (budget) $0.25 per 1M input tokens, $1.50 per 1M output tokens
input 1,000 x $0.25 / 1M = $0.00025
output 500 x $1.50 / 1M = $0.00075
per call = $0.00100 (a tenth of a cent)The 500 output tokens assume a short answer with little hidden reasoning. So far, so cheap. The reasoning tier is where it stops being cheap. OpenAI’s reasoning guide says reasoning tokens are billed as output tokens, and that a model may generate anywhere from a few hundred to tens of thousands of them. Anthropic’s usage reporting likewise counts thinking tokens among billed output tokens. Assume one answer that uses 30,000 output tokens at $50 per million, the rate OpenAI lists for its flagship gpt-6-astra: that’s $1.50 in output alone.
| Tier (example) | Cost of one answer (October 2026 list prices) | What drives it |
|---|---|---|
| Budget (Gemini 3.1 Flash-Lite) | ~$0.001 | Low per-token rates |
| Mid-priced (gpt-5.4) | ~$0.01 | An assumed 1,000 tokens in, 500 out |
| Reasoning answer at $50 per 1M output tokens | ~$1.50 | An assumed 30,000 output tokens, mostly hidden reasoning |
That’s not a typo. One answer, about 150 times the cost of the mid-priced call, for a question you might have been able to answer with a join.
Why does an LLM call feel free until it isn’t?
Because at development volume the unit cost is too small to notice. At ten calls a day, a cent each is ten cents, and a dollar-fifty answer once in a while is easy to miss too. That’s the trap: the unit cost is small enough to ignore right up until the unit count isn’t, and the count changes the day real traffic arrives.
An LLM call is metered. Every request is a fresh charge against a per-token meter, so the bill scales with usage: more users, more calls, a bigger inference line. Nothing about the feature changed between the demo and the invoice except the count. For the wider version of this problem across a cloud bill, see database choices that quietly kill your AWS bill.
What does a SQL query cost next to that?
Next to an LLM call, a well-indexed SQL query on a provisioned database is effectively free at the margin. You pay for the instance for the time it runs, busy or idle, so one more indexed lookup carries no charge of its own. The query rides on a cost you’re paying regardless, on capacity you’ve already bought.
That’s the structural difference, and it’s worth stating plainly. Amazon RDS, for example, bills an On-Demand instance per hour it runs. One pricing model scales with usage; the other doesn’t, until you outgrow the instance. Serverless databases meter usage differently, so check which one you’re on.
| LLM call | Indexed SQL query (provisioned database) | |
|---|---|---|
| Pricing model | Metered: a fresh per-token charge on every request | Time-based: the instance is billed while it runs |
| Cost of one more request | The full per-token price, again | No charge of its own |
| Grows with traffic | Yes, with every call | Only when you need a bigger instance |
| Where the time goes | Generating output, one token at a time | Executing the query plan, plus the network round trip |
| Result | Generated text, which can be wrong | The stored value, exactly |
The cleanest case is the one where the answer is already a column:
-- the answer is a column, fetched with one indexed lookup
SELECT plan_tier, seats_remaining
FROM accounts
WHERE id = $1;There’s no model to wait on and no tokens to count, and the result is the stored value rather than a generated approximation. In the PostgreSQL manual’s own EXPLAIN ANALYZE examples, index lookups on its small test tables execute in hundredths of a millisecond; bigger tables, cold caches and the network round trip add to that. The boring tools already in your stack can cover more of these cases than you might assume; Postgres does more than you think walks through them.
Keeping the access pattern cheap is mostly an indexing question, covered in indexing strategies: when each index type actually pays off.
Why does the latency gap matter as much as the cost?
Because latency compounds, and the model spends its time somewhere an index can’t help. OpenAI’s latency guide says generating tokens is almost always the highest-latency step of an LLM call, and that cutting output tokens by half may cut latency by about half. An indexed lookup generates nothing: it reads what’s already stored.
Model latency varies with the provider, the load, the prompt and the output length, so this article doesn’t quote general figures; measure time to first token and total response time on your own prompts. The structural comparison holds either way:
| Operation | Where its time goes |
|---|---|
| Indexed database lookup | Walking the index and reading a few pages, plus a network round trip |
| Model call, time to first token | Sending the prompt and processing the input before any output appears |
| Model call, full response | Generating every output token in turn, including any hidden reasoning tokens |
Reasoning models sit at the far end because they can generate thousands of reasoning tokens before the visible answer starts.
How does LLM latency compound in an agent loop?
Step by step, with every call the agent makes in sequence. If each call waits for the one before it, per-call latency multiplies by the number of steps. Take an illustrative assumption of 600 milliseconds to first token per call: a four-step agent spends 2.4 seconds before it produces anything. At an assumed 2,400 milliseconds per call, that’s 9.6 seconds.
Four-step agent, one model call per step, run in sequence
(illustrative time-to-first-token assumptions, not benchmarks)
faster model 4 x 600 ms = 2.4 s
slower model 4 x 2,400 ms = 9.6 sThose are the seconds before each step’s first useful output, not the time to finish, and every extra request adds its own round trip. Every step you could have answered with a query is latency you didn’t have to pay, on top of the per-token charge you didn’t have to pay either.
So when should a question go to the model instead of the database?
When the answer isn’t stored as a value a query can return. A WHERE clause can filter, join and aggregate what’s in your tables, but it can’t summarise a free-text support ticket, draft a reply, or pull fields out of an unstructured document. That’s where the model earns its per-token price. If a query can produce the answer, use the query.
Four questions help settle these design-review debates:
- Is the answer already in your data? If it’s a column, or a join away, the query wins on cost, latency and exactness. Sending it to a model buys a slower, metered, generated version of an answer you already have.
- Does the task need language rather than lookup? Summarising, classifying free text, extracting fields from documents and drafting replies are jobs a query alone can’t do. That’s the work worth paying per token for.
- How many times will this run? At ten calls a day, the cost is cents. At production volume, multiply the per-call price by the real request count, and then by every call an agent makes per user action.
- Which model tier is on the path, and is someone waiting? A long reasoning answer can cost more than a hundred times a short mid-priced call. A single answer a user asked for can absorb the wait; a hot request path or a multi-step agent turns it into the whole experience.
The same discipline, making the expensive or specialized tool justify itself before it joins the design, applies to vector databases as well. More on the data side of these trade-offs lives in the databases hub.
An LLM call and a SQL query are priced and timed on different scales. When the answer is already stored, that gap is the decision. When the task needs language, the model is the tool that can do it.
Key takeaways
- An LLM call and a SQL query aren't interchangeable tools with different price tags. One is metered per token; the other runs on capacity you already pay for.
- At October 2026 list prices, a call of 1,000 tokens in and 500 out costs about a cent on gpt-5.4 and a tenth of a cent on Gemini 3.1 Flash-Lite. An assumed 30,000-token reasoning answer at $50 per million output tokens costs about $1.50.
- LLM calls are metered per token, so cost grows with every request. A provisioned database instance is billed for the time it runs, so one more indexed query carries no charge of its own.
- Cheap is a property of the access pattern: a sequential scan or an N+1 loop throws the query's advantage away.
- Latency compounds. Generating output tokens is usually the slowest part of a model call, and an agent that makes its calls in sequence waits for every one.

Questions people ask
How much does an LLM API call cost?
It depends on the model and the token count. At October 2026 list prices, a call of 1,000 input and 500 output tokens costs about a cent on OpenAI's gpt-5.4 ($2.50 and $15 per million tokens) and a tenth of a cent on Google's Gemini 3.1 Flash-Lite ($0.25 and $1.50). Prices change often, so check current rate cards.
Why do reasoning models cost so much more per call?
Because their hidden reasoning tokens are billed as output tokens, and OpenAI's docs say a model may generate anywhere from a few hundred to tens of thousands of them for one request. At a $50-per-million output rate, an answer that uses 30,000 output tokens costs about $1.50, roughly 150 times a one-cent mid-priced call.
Is a SQL query really free compared with an LLM call?
At the margin, an indexed one on a provisioned database effectively is. The instance is billed for the time it runs, busy or idle, so one more indexed lookup carries no charge of its own. Serverless databases meter usage differently, and a sequential scan or an N+1 loop still wastes capacity: cheap is a property of the access pattern.
How much slower is an LLM call than a database query?
It depends on the model, the prompt and the output length, so measure your own. Two documented facts frame it: OpenAI's latency guide says generating tokens is almost always the slowest step of an LLM call, and the PostgreSQL manual's EXPLAIN ANALYZE examples show index lookups executing in hundredths of a millisecond. Network round trips add to both.
When does LLM latency actually matter?
In loops and hot paths. An agent that makes one model call per step, in sequence, waits for each call in turn, so per-call latency multiplies by the number of steps. For a single answer a user asked for, the wait is often acceptable; on a path that runs on every request, it becomes the whole experience.
Get the next article by email
One email when a new deep-dive is out: databases, cloud and AI, with the code. Unsubscribe in one click.
Email signups open soon. Until then, new articles are announced on Instagram.
