Answer
How should AI read your database without breaking anything?
Through a read-only account against a replica, with the schema supplied and a limit on what a single query can cost.
A read-only account, pointed at a replica or a restricted set of views, with the schema supplied and a cost or row limit on each query. The risk is a slow query on production, not a malicious one.
The risk that people design for is modification and the risk that actually materialises is load. A generated query that joins several large tables without an index, or scans a table that should have been filtered, will run, will be correct, and will make the database slow for everyone else. Read-only access prevents none of this, which is why the permission decision and the performance decision are separate.
So the arrangement has four parts. A dedicated account with read-only rights, so nothing can be modified whatever is generated. A replica or a restricted set of views rather than the production tables, so load lands somewhere it does not matter and the exposed surface is chosen rather than inherited. Limits — statement timeout, row cap, cost ceiling — so a single expensive query fails rather than degrading the system. And the schema supplied as context, which is what makes the generated queries correct in the first place.
The schema point is worth expanding because it is the difference between a system that works and one that guesses. A model asked to query a database it cannot see will produce plausible table and column names, and those queries fail loudly, which is the good case. Supplied with the actual schema, including which columns mean what and how tables relate, it produces correct queries — and the descriptions matter as much as the names, because a column called status does not explain its permitted values.
Views are underrated here and solve several problems at once. A view exposes the columns you intend, excludes the sensitive ones, applies the filters that would otherwise have to be remembered, and gives the joins a name rather than requiring them to be reconstructed. A small set of well-named views is easier to query correctly than a normalised schema and is also the access boundary, which means one artefact is doing both jobs.
The output needs the same treatment as any other generated result. A query that returned rows is not a query that answered the question: the wrong filter, a missing condition or an unintended join produces a plausible number from real data, which is harder to doubt than an invented one. Where a figure matters, the query itself should be visible alongside the result so that it can be read rather than trusted.
Finally, log the queries. What was asked, what was generated, what it returned, how long it took. This is what lets you find the expensive ones, notice the ones that ran against something they should not have reached, and answer the question of where a figure came from three weeks later. It costs almost nothing and is the difference between a facility and an unaccountable one.
The damage a reading system does to a database is usually a table scan at four in the afternoon, not a deletion.
Siddharth Sharma, Context Theory
Related questions
Should AI be allowed to write to a database at all?
Through a defined operation rather than a generated statement. A system calling a procedure that inserts a row with validated arguments is doing something bounded; a system generating an update statement is not, and the difference is whether the shape of the change was decided in advance by a person.
What about tools that let you ask questions of your data in plain English?
They are this arrangement with the parts hidden, which is convenient and makes the same questions worth asking: what account does it use, does it reach production, can it modify anything, and can you see the query it ran. A tool that will not show you the query is asking to be trusted about arithmetic, which is the one thing not to trust.
METHOD
Every figure below carries its source and the date it was verified. Nothing on this page is asserted.
The numbers on this page.
| What | Value | Specific to |
|---|---|---|
| Sub-15-minute compliance — automated routing vs manual only | 62.5% vs 39.1% | Category-wide |
| Close rate — response under 5 minutes vs over 24 hours | 32% vs 12% | Category-wide |
2026 speed-to-lead benchmark · verified
Optifai speed-to-lead benchmark · n=939 companies · Q2 2025–Q1 2026 · verified
What is specific to this page.
| Kind | Claim | Check it against |
|---|---|---|
| Software | The realised risk from generated queries is load rather than modification, because a correct query joining or scanning large tables degrades the database for other users and read-only permissions prevent none of it. | Running a generated query against a large table without an index and observing its effect on concurrent queries. |
| Workflow | Supplying the schema with column meanings and relationships is what makes generated queries correct, because names alone do not convey permitted values or intent, and a model without the schema produces plausible names that fail. | Comparing generated queries with and without the schema and column descriptions supplied. |
| Constraint | A small set of named views simultaneously exposes the intended columns, excludes sensitive ones, embeds required filters and names the joins, so one artefact serves as both the query interface and the access boundary. | Comparing query correctness against a normalised schema and against purpose-built views. |
| Response | A query returning rows has not necessarily answered the question, because a wrong filter or unintended join produces a plausible figure from real data, which is harder to doubt than an invented one. | Comparing a generated query's logic against the question it was asked to answer. |
Each row would be wrong on another industry's page. Where a sourced figure exists it is in the table above instead; these are the constraints that shape the work and do not happen to be numbers.
Start with the measurement.
Reading about a benchmark is not the same as knowing your own number. The audit produces yours, measured rather than estimated.
$497 · delivered in 5 business days · credited against month one