Text-to-SQL Execution Controls: Read-Only, Limits and Cancellation
Evaluate read-only database access, query timeouts, cost limits and cancellation for text-to-SQL tools. Includes a runnable example and acceptance worksheet.

Read-only access, query timeouts, cost limits and cancellation solve different problems. When choosing a text-to-SQL tool, verify which controls the database enforces, which the application implements, and which still need configuration. A prompt saying “only run SELECT” or a Stop button does not establish all four.
For AskYourDatabase, start with an administrator-provisioned reporting account and test the chosen Desktop, Website Chatbot or private-deployment path. For a draft-first workflow, Metabase Metabot's native SQL editor provides a different review point. Neither product label replaces checking the underlying database identity and execution settings.
This guide focuses on what a generated query is allowed to do and how its work ends. Use the SQL visibility guide to review an answer, the audit-log guide for retained evidence, and the embedded user-context guide for identity and page context. Those tasks remain separate.
AskYourDatabase publishes this guide. Product code and the linked official documentation were reviewed on November 20, 2026. The runnable control example is an authored, local SQLite demonstration, not a vendor benchmark or production security test. Take the acceptance worksheet into a scoped evaluation.
Separate the controls before comparing tools
| Requirement | What to establish | Evidence that is insufficient |
|---|---|---|
| Prevent writes | The effective database identity cannot perform disallowed changes | A prompt rule or a query starting with SELECT |
| Restrict readable data | Approved objects, columns and rows for the actual user | A shared account described as read-only |
| Bound running work | An engine or executor limit applies to the submitted statement | A connection-establishment timeout |
| Bound costs | A relevant workload or job policy applies, with documented limitations | A small response or a chart with ten points |
| Stop running work | The engine reports cancellation or another terminal outcome | The browser stops receiving tokens |
| Require approval | Execution cannot begin until the authorized reviewer approves | SQL displayed after the query has already run |
| Bound retries | Attempts and cumulative work are limited and visible | Each individual attempt has a timeout |
Write the required behavior before a demo. For example, “an ordinary user cannot update the reporting fixture” is testable. “Enterprise-grade guardrails” does not identify an operation, identity or outcome.
A read-only transaction setting is useful evidence about a transaction, but it is not a complete privilege review. Check inherited roles, callable functions and access to sensitive objects with the database administrator. Restrict the reporting surface independently of model instructions. Use a disposable environment for denied-operation tests, and confirm that the rows stayed unchanged.
Choose the workflow and its enforcement owner
| Workflow | Documented starting point | What your evaluation must still demonstrate |
|---|---|---|
| AskYourDatabase conversational analysis | Connect an approved database and use a restricted reporting identity | Effective permissions, actual engine limits, cancellation behavior and any required approval step in the selected product |
| Metabase Metabot in the native SQL editor | Generated SQL can be inspected before the user runs the draft | The intended user's execution privileges and database-side workload controls; other Metabot surfaces may behave differently |
| A custom application using a SQL-generation API | Your application owns the transition from generated SQL to execution | Authorization, validation, limits, retries, cancellation and evidence collection throughout that executor |
Metabase documents the native-editor workflow, including that drafting SQL there does not automatically run it. That narrow workflow is useful when manual review is mandatory; it is not a claim about every AI interaction in Metabase.
AskYourDatabase's connection guide and security documentation describe database preparation and processing boundaries. Its conversational query workflow should not be assumed to pause for approval merely because a reviewer can inspect SQL. If approval before every execution is a hard requirement, demonstrate it in the intended interface before selecting that workflow.
For a broader product replacement decision, see the AskYourDatabase and BlazeSQL comparison. This article supplies an execution-control acceptance process; it does not rank vendors by untested security claims.
Apply engine controls to the actual execution path
Database features are useful only if the application uses the identity and session or job configuration you checked. A successful test in an administrator's console does not configure the chatbot's pooled connections.
PostgreSQL: client connection settings distinguish statement_timeout, lock_timeout and read-only transaction defaults. A statement timeout bounds elapsed statement execution; a lock timeout addresses lock waits. Have the administrator choose workload-appropriate settings, inspect the effective values in the application's session, and test them. Do not treat a mutable default as an immutable security boundary.
BigQuery: maximum bytes billed can reject an on-demand query when its pre-execution estimate exceeds the configured limit. A dry run estimates processing without running the query, but estimates have limitations, including external sources and row-level security. Verify how the actual job receives its settings. A console dry run does not automatically place that policy on later application jobs.
Snowflake: STATEMENT_TIMEOUT_IN_SECONDS is an execution setting with scope and precedence rules. Check the effective session and warehouse configuration used by the application. Retain the query identifier and terminal outcome when testing the chosen bound.
These examples describe engine mechanisms, not a promise that every AskYourDatabase connector exposes each setting as a UI option. Choose one supported database and demonstrate its end-to-end behavior before generalizing to others.
A short response is not a short query
Consider three invented reporting rows with amounts of 12,500, 2,500 and 3,000 cents. This SQLite statement returns just one row:
SELECT COUNT(*) AS orders, SUM(cents) AS total_cents
FROM report_orders
LIMIT 1;
The answer is 3 orders and 18,000 cents. LIMIT 1 applies to the aggregate result; it does not restrict the aggregate to the first input order. On a real workload, joins, aggregation or sorting may perform substantial work before a small result exists. Use the engine's plan and execution evidence to evaluate that work.
Likewise, trimming results after execution can reduce response size without reducing the work already done. AskYourDatabase's shared connector path includes result shortening after the connector returns. That behavior is not a scan or billing limit. The BigQuery connector reviewed for this guide calls the query client with SQL; this review does not establish a configurable per-request bytes cap in the product interface.
The downloadable reference creates only an in-memory SQLite database. Run it with python3 control-example.py; no credentials, network access or existing database files are used. Its ten checked outcomes are:
- An approved aggregate returns 18,000 cents.
- A separate read policy denies a synthetic private table.
- Update, insert, delete and table creation are denied by SQLite query-only mode—four separate checks.
- The approved total is unchanged after those denied writes.
- An aggregate with
LIMIT 1still counts all three input rows. - A fixed recursive statement is interrupted by a virtual-machine work budget.
- The connection runs an approved query after the interruption.
The budget counts progress callbacks, not seconds or money. The script runs only fixed authored statements; it is not a sandbox for arbitrary user SQL, a replacement for server permissions, or evidence that a vendor passes these cases. Its value is making distinct outcomes observable before you design the real evaluation.
Verify cancellation, timeout and retries separately
A request can stop waiting while the database continues working. AskYourDatabase's reviewed API execution path includes a response-timeout race; that code alone is not evidence that the engine receives a cancellation request. Treat an HTTP timeout as a response outcome until database evidence establishes what happened to the statement.
In a disposable test environment, ask the administrator to select a bounded workload suitable for checking cancellation. Record the application request and database job or statement identifier. Trigger the documented Stop or timeout behavior, then inspect the engine outcome. Do not deliberately stress a production warehouse to discover whether a limit exists.
Check three cases separately: an application deadline, a user cancellation and a disconnected client. For each, record whether work completed, failed, was cancelled or remains running. If a retry follows, count it as new work with its own identifier. A timeout followed by repeated automatic retries can consume more total resources than a single attempt.
After an error or cancellation, verify connection reuse: transaction state, identity, scope and limits must be appropriate for the next request. For pooled connections, testing only the first session misses reuse behavior. Keep an unknown outcome marked unknown instead of treating silence as successful cancellation.
Evaluate AskYourDatabase with one reporting workload
Choose Desktop for an individual analyst or Website Chatbot for an application workflow. Use an approved reporting datasource, an administrator-managed limited account and a known aggregate. For embedded users, configure access control and test real authenticated sessions; a database read-only account alone does not isolate customers.
AskYourDatabase training interface. This is a product screenshot, not output from the SQLite control demonstration.
Add the metric definition and reviewed examples using training. Context helps the assistant interpret the task; it does not grant or enforce database privileges. Ask an ordinary reporting question, inspect the query and result, and compare them with a known reference. Then have the deployment team run the agreed denied-operation and execution-limit cases on disposable data using the same application path.
Record product version, connector, effective identity, execution settings, expected outcome and observed evidence in the worksheet. Include a technical owner who can inspect the engine, a business owner who can verify the answer, and the application owner responsible for retries and user identity. A mandatory fail or unknown blocks rollout for that requirement.
Choose plans after deciding the audience and deployment. If your requirements include a hard cost cap, approval gate, verified cancellation or private hosting, discuss the required configuration with the team and ask for a scoped demonstration. Private application hosting and read-only access do not by themselves establish local-only model processing. Keep the first rollout limited to the workload and controls actually verified.
Frequently asked questions
Which text-to-SQL tools support read-only access and query execution controls?
Evaluate the complete tool and database path. AskYourDatabase can connect using a database account restricted by its administrator; Metabase Metabot's native editor supports reviewing generated SQL before running it. Engine controls such as PostgreSQL statement timeouts and BigQuery maximum bytes billed require configuration and verification on the actual execution path. These are not equivalent feature bundles.
Does read-only access prevent expensive queries?
No. A read-only query can still scan substantial data or consume compute. Restrict readable objects and configure appropriate execution and cost controls separately.
Does stopping a chatbot response cancel the database query?
Not necessarily. Stopping the interface, ending an HTTP request and cancelling an engine job are different actions. Verify the terminal database job or statement state and check whether retries start new work.
Is LIMIT a query cost cap?
No. LIMIT constrains output rows, but an aggregate or sort may still process many inputs. BigQuery documents that LIMIT does not reduce compute costs on non-clustered tables.
Does AskYourDatabase provide a universal timeout or cost-limit guarantee?
This guide makes no such guarantee. Confirm the product, connector and database configuration. A response timeout or shortened result does not establish engine cancellation, a scan limit or a billing cap.
What does the downloadable example prove?
It checks ten outcomes for fixed statements against synthetic in-memory SQLite data: approved reading, denied reads and writes, an aggregate with LIMIT, interruption and connection reuse. It does not test AskYourDatabase, an AI model, production permissions, a wall-clock timeout or cloud billing.
