An AI agent writes SQL like a confident junior: fluent, plausible, and sometimes wrong in ways that are expensive and quiet. The difference is throughput. A person writes a handful of queries a day; an agent produces them faster than any reviewer can keep up with, and each one runs as a database principal with whatever rights you gave it. The right mental model is not "review the SQL" but "treat the query as untrusted code moving through a release pipeline."
The stakes are concrete. A read-modify-write statement with a missing predicate is a mass update. A join on an unindexed column over a large table is a sequential scan that pins CPU for as long as the statement runs. A select with no limit can push millions of rows into an application that then runs out of memory. Most of these are not malicious; they are the result of a model optimizing for "does the query answer the question" and not for "will this query survive contact with a production schema."
Worked example with numbers. Suppose a customer table holds 4 million rows at roughly 500 bytes each, so the table on disk is about 2 GB. A full sequential scan moves that 2 GB through the buffer cache and then through the client. If your warehouse bills $25 per terabyte scanned, one unindexed query costs roughly 5 cents. Run it hourly as a daily-active-users task and you have moved about 17.5 GB a day, roughly 44 cents, for one table. That is tolerable. The same mistake on an events table a hundred times larger is not: the cost model is linear, the operational consequence is not, and a full scan can starve a replica your customers depend on.
There is a second reason to build this discipline: reproducibility. If you can later show that a query passed review with a specific plan and a specific row count on a clone, you can defend the result to a customer or an auditor. If you cannot, you are trusting a chat log.
The workflow below works for any relational engine. Where the examples use PostgreSQL syntax, check your engine's equivalents; the gates are portable even when the commands are not.



