<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: David Murray</title>
    <description>The latest articles on DEV Community by David Murray (@davidmurray).</description>
    <link>https://dev.to/davidmurray</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4082887%2Ff10ab795-36e3-4a14-af0b-801c47c8fff3.jpg</url>
      <title>DEV Community: David Murray</title>
      <link>https://dev.to/davidmurray</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/davidmurray"/>
    <language>en</language>
    <item>
      <title>Build a Pre-Deployment Schema Drift Check for SQL Server</title>
      <dc:creator>David Murray</dc:creator>
      <pubDate>Fri, 13 Nov 2026 17:10:26 +0000</pubDate>
      <link>https://dev.to/davidmurray/build-a-pre-deployment-schema-drift-check-for-sql-server-5dda</link>
      <guid>https://dev.to/davidmurray/build-a-pre-deployment-schema-drift-check-for-sql-server-5dda</guid>
      <description>&lt;p&gt;&lt;em&gt;A repeatable gate that stops a release when the target database is not what the release expects&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Most database pipelines verify the change: the migration compiles, the tests pass, the reviewer approves. Far fewer verify the target. Yet a correct migration can still fail if the database it lands on has drifted from the state the release was built against.&lt;/p&gt;

&lt;p&gt;This post walks through a practical drift check you can run before every SQL Server deployment. You define a reference schema, compare it against your environments, classify what you find, and turn the result into something a person reviews instead of an automatic sync.&lt;/p&gt;

&lt;h2&gt;
  
  
  The failure mode
&lt;/h2&gt;

&lt;p&gt;Drift breaks releases in two directions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Something is missing from production.&lt;/strong&gt; A developer adds a column directly to a staging table while building a feature. The application code starts reading that column, every test in staging passes, and the change never makes it into the release migration. In production the column does not exist, so the new code fails the first time it runs that query.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Something exists only in production.&lt;/strong&gt; An index is created in production during an incident and never recorded in the approved schema. A later synchronization sees it as an unknown object and drops it. Nothing errors out, but a query that used to be fast becomes slow, and no code changed.&lt;/p&gt;

&lt;p&gt;Other common causes include hotfixes that never flow back to development, test databases restored from older backups, and environments running different SQL Server versions or compatibility levels. Tests that only run against test will not catch any of them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Pick a reference schema
&lt;/h2&gt;

&lt;p&gt;Before you compare anything, decide what "correct" means. Dev is a poor default because it is where experiments live. Common choices:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a release-approved staging database&lt;/li&gt;
&lt;li&gt;a set of versioned release scripts&lt;/li&gt;
&lt;li&gt;a schema snapshot taken at release time&lt;/li&gt;
&lt;li&gt;a source-control revision&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every environment gets compared against this reference, not against each other. Without it, a comparison only shows that two databases disagree.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Know the limits of hand-rolled metadata checks
&lt;/h2&gt;

&lt;p&gt;The usual first attempt is a query against INFORMATION_SCHEMA views in two databases, using a set operation to find columns that exist in one but not the other. It is a reasonable starting point, but it runs out of road quickly:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;It is often one-directional.&lt;/strong&gt; A simple diff shows what one side has that the other lacks, but not the reverse, unless you write and maintain both directions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Type names are not definitions.&lt;/strong&gt; Two columns can share a data type name and still differ in length, precision, scale, nullability, or default value.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Coverage is partial.&lt;/strong&gt; Microsoft documents that INFORMATION_SCHEMA exposes only part of SQL Server's metadata. A complete check has to reach into the system catalog views for indexes, constraints, procedures, triggers, views, and permissions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Environment quirks get in the way.&lt;/strong&gt; Cross-database comparisons can run into collation conflicts when the databases do not share a collation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It does not interpret anything.&lt;/strong&gt; A query can tell you &lt;em&gt;that&lt;/em&gt; something differs. It cannot tell you whether the difference is planned, intentional, or a problem.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you extend it to cover all of that, you are maintaining your own schema comparison tool. That is usually the signal to use one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Classify every difference
&lt;/h2&gt;

&lt;p&gt;A diff is not a deployment plan. Sort each result into one of these buckets:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Planned change:&lt;/strong&gt; in the reference, missing from the target. This is what the release should deploy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Legitimate local change:&lt;/strong&gt; exists only in the target for a good reason, such as an incident index. Bring it back into the reference instead of deleting it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Needs a decision:&lt;/strong&gt; both sides have the object but the definitions differ, for example a procedure patched in production. Someone must choose the correct version.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Accepted difference:&lt;/strong&gt; known and expected. Filter it out so it stops appearing in every run.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The rule for the pipeline is simple: anything left after filtering must be explainable before deployment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Make the comparison repeatable with dbForge Studio
&lt;/h2&gt;

&lt;p&gt;In &lt;a href="https://www.devart.com/dbforge/sql/studio/" rel="noopener noreferrer"&gt;dbForge Studio for SQL Server&lt;/a&gt;, you create a new schema comparison from the Comparison menu, set the reference schema as the source and the environment under check as the target, and run it. The results show objects that are missing, different, or present on only one side.&lt;/p&gt;

&lt;p&gt;From there, the workflow maps directly onto the classification above:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;filter out accepted differences so they stop cluttering results&lt;/li&gt;
&lt;li&gt;select only the changes that belong in the release&lt;/li&gt;
&lt;li&gt;generate a synchronization script for review rather than syncing directly&lt;/li&gt;
&lt;li&gt;produce a comparison report that reviewers can read without opening the tool&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The comparison settings can be saved to a project file and reused, so the same check runs the same way every time. In the Professional and Enterprise editions, that saved comparison can run from the command line, producing the report and a proposed synchronization script without changing the target database. That is the piece that lets the check live inside a pipeline instead of on someone's desktop.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Wire it into the pipeline
&lt;/h2&gt;

&lt;p&gt;A minimal pre-deployment stage looks like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Run the saved comparison from the reference to &lt;strong&gt;test&lt;/strong&gt;. If test has drifted, your test results do not describe the release.&lt;/li&gt;
&lt;li&gt;Run the saved comparison from the reference to &lt;strong&gt;production&lt;/strong&gt;. This is the actual drift gate.&lt;/li&gt;
&lt;li&gt;Publish the comparison report and the proposed synchronization script as build artifacts.&lt;/li&gt;
&lt;li&gt;If unexpected differences remain after filtering, fail the stage and route the artifacts to a reviewer.&lt;/li&gt;
&lt;li&gt;Run the real migration only after the review is complete.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Check your version's command-line documentation for how comparison results are reported back to the calling process, and base the gate on that.&lt;/p&gt;

&lt;p&gt;What not to do: apply the proposed synchronization script to production automatically. Automate the detection, not the synchronization.&lt;/p&gt;

&lt;h2&gt;
  
  
  Review checklist for generated sync scripts
&lt;/h2&gt;

&lt;p&gt;Before anyone approves a synchronization script, look for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;table rebuilds on large tables&lt;/li&gt;
&lt;li&gt;data type conversions that could truncate values or fail&lt;/li&gt;
&lt;li&gt;dropped indexes, especially ones that only existed in production&lt;/li&gt;
&lt;li&gt;permission changes&lt;/li&gt;
&lt;li&gt;any statement that could lose data&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;Schema drift is the sum of small, reasonable changes that nobody reconciled. A reference schema, a two-direction comparison, a classification step, and a pipeline gate that produces artifacts instead of applying changes will catch most of it before it reaches users.&lt;/p&gt;

&lt;p&gt;The sequence to remember: &lt;strong&gt;Compare → Review → Select → Generate script → Approve → Deploy.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The deployment should never be the first thing that discovers the drift.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Further reading: &lt;a href="https://dev.to/databaseinsights/how-to-detect-schema-drift-before-production-deployments-50lk"&gt;How to Detect Schema Drift Before Production Deployments" by Database Insights on DEV Community&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>sql</category>
      <category>sqlserver</category>
      <category>devops</category>
      <category>database</category>
    </item>
    <item>
      <title>AI Agents Can Run SQL Now. Where Should Database Teams Draw the Line?</title>
      <dc:creator>David Murray</dc:creator>
      <pubDate>Tue, 27 Oct 2026 17:08:45 +0000</pubDate>
      <link>https://dev.to/davidmurray/ai-agents-can-run-sql-now-where-shoulddatabase-teams-draw-the-line-2e14</link>
      <guid>https://dev.to/davidmurray/ai-agents-can-run-sql-now-where-shoulddatabase-teams-draw-the-line-2e14</guid>
      <description>&lt;p&gt;For most developers, AI in database work has meant one thing so far: typing less. You describe what you need, a model drafts the SQL and you decide what to keep. The tool got smarter every year, but the shape of the job stayed the same. You were still the one who pressed Run.&lt;/p&gt;

&lt;p&gt;Agentic AI changes the shape of the job. An agent can inspect a schema, execute a query, read the result and decide what to do next on its own. The question in front of database teams is no longer whether AI can write good SQL. It clearly can. The question is how much of the decision to run that SQL we are prepared to hand over, and who answers for the outcome when we do.&lt;/p&gt;

&lt;p&gt;That makes this a design conversation about authority, not about models.&lt;/p&gt;

&lt;h2&gt;
  
  
  The control nobody designed
&lt;/h2&gt;

&lt;p&gt;Look back at the assistant era and something stands out. The most effective safety mechanism in AI-assisted SQL was never a feature. It was a habit. A person read the output before it touched the database, and that single step absorbed most of the risk.&lt;/p&gt;

&lt;p&gt;Because it was a habit, it is easy to lose without noticing. Give an agent execution rights and the step simply disappears. Nothing breaks on day one. The system just becomes faster and less supervised at the same time.&lt;/p&gt;

&lt;p&gt;That is why "can the agent do this?" is the wrong first question. The better one is "what did the human review step used to protect us from, and where does that protection live now?"&lt;/p&gt;

&lt;h2&gt;
  
  
  Same SQL, different owner
&lt;/h2&gt;

&lt;p&gt;The SQL an agent runs is often identical to what an assistant would have suggested. An agent that spots a slow query might create an index, rerun the workload and confirm the gain, exactly as a developer would.&lt;/p&gt;

&lt;p&gt;The difference is not the statement. It is who owns the judgment behind it. A developer weighs a change against things that never appear in a query plan: which services depend on that table, what the write load looks like at peak, whether a deployment freeze is in effect. An agent sees what it has access to, and that is usually less than it seems.&lt;/p&gt;

&lt;p&gt;So a technically reasonable decision can still be wrong for the environment. Because agents act in sequences, small misjudgments compound. A slow read is a nuisance. A loosely scoped update or an unexpected schema change is an incident.&lt;/p&gt;

&lt;h2&gt;
  
  
  Databases encode business decisions
&lt;/h2&gt;

&lt;p&gt;This is where database work differs from most of what AI coding tools are optimized for. Application code expresses logic. Databases also hold obligations.&lt;/p&gt;

&lt;p&gt;Consider the kind of cleanup an agent might reasonably propose:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;DELETE&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;AuditLog&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;CreatedAt&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;DATEADD&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;year&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;GETDATE&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The statement is valid. Whether it is acceptable depends on facts no schema records: a regulatory retention period, an application that still reads those rows, a requirement to archive before deleting, an operational need to run the change in batches.&lt;/p&gt;

&lt;p&gt;Treating database development purely as a code-generation problem misses this. Many database operations are business decisions wearing technical clothing. A model can master the technical part and still have no way of knowing the business part. That is not a flaw a better prompt will fix. It is a boundary to design around.&lt;/p&gt;

&lt;h2&gt;
  
  
  Authority is an architecture concern
&lt;/h2&gt;

&lt;p&gt;Agent permissions therefore belong in the same conversation as schema design and deployment strategy, not in a config file someone edits on a Friday afternoon.&lt;/p&gt;

&lt;p&gt;A few principles follow:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Separate seeing from doing.&lt;/strong&gt; Most of an agent's value comes from reading: explaining plans, spotting inefficient indexes, reviewing dependencies, diagnosing errors. Broad visibility and broad execution rights are two different decisions and should be made separately.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Agents are principals, not proxies.&lt;/strong&gt; Letting an agent run under the developer who launched it is the most convenient setup and the least defensible one. An agent should have its own identity, scoped to its job, exactly as a service account would. OWASP calls the opposite pattern "excessive agency" and treats it as a core risk for LLM applications.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Human approval is part of the system.&lt;/strong&gt; For destructive DDL, production data changes, permission changes and large migrations, a review step is not friction slowing the agent down. It is the component that carries accountability.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A workflow that reflects this looks something like &lt;strong&gt;Observe → Analyze → Propose → Review → Execute → Validate → Record&lt;/strong&gt;. The agent can do almost all of it, including testing a change in staging and measuring the result. What it does not do is promote a high-impact change to production on its own judgment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Autonomy should be earned in stages
&lt;/h2&gt;

&lt;p&gt;None of this argues for keeping agents permanently read-only. It argues for sequencing. Start with explanation and analysis. Let agents make changes in development and staging. Introduce production write access later, with clear limits on affected rows, transaction boundaries, rollback, monitoring and approval. Keep fully autonomous production changes rare.&lt;/p&gt;

&lt;p&gt;Most organizations are still early on this curve. McKinsey's 2025 State of AI survey found that no more than 10% of respondents reported scaling AI agents in any given business function. Gartner, meanwhile, expects more than 40% of agentic AI projects to be canceled by the end of 2027, with inadequate risk controls among the reasons. The teams that scale agents successfully are likely to be the ones that built the controls first and granted the permissions second.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this means for developers
&lt;/h2&gt;

&lt;p&gt;If agents take on more of the repetitive work, the developer's role shifts rather than shrinks. The valuable skills move toward:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;reviewing AI-proposed changes with the same rigor as a teammate's pull request&lt;/li&gt;
&lt;li&gt;making implicit context explicit, so that retention rules, dependencies and constraints are written down somewhere an agent or a reviewer can find them&lt;/li&gt;
&lt;li&gt;defining the boundaries of agent authority deliberately instead of inheriting them by default&lt;/li&gt;
&lt;li&gt;owning the outcome of every high-impact change, regardless of who drafted it&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The tools worth adopting are the ones that support this division of labor rather than blur it. &lt;a href="https://www.devart.com/dbforge/ai-assistant/" rel="noopener noreferrer"&gt;dbForge AI Assistant&lt;/a&gt; is one example of that design. It works inside dbForge tools from database metadata rather than table data to generate, explain, optimize and troubleshoot SQL, and it returns the result to the developer to review and run.&lt;/p&gt;

&lt;h2&gt;
  
  
  The question worth asking
&lt;/h2&gt;

&lt;p&gt;The most useful database agent will not be the one allowed to do the most. It will be the one whose authority the whole team understands: what it can see, what it can change, under which identity and who signs off.&lt;/p&gt;

&lt;p&gt;So the conversation to have with your team is not "should we let AI run queries?" It is "which queries, under what constraints and with whose approval?" Teams that answer that clearly will get the productivity of agents without giving up the judgment that keeps databases trustworthy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How is your team drawing that line today? Share where you have set the boundary in the comments.&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;For a deeper look at this topic, read &lt;a href="https://www.unite.ai/agentic-ai-database-development-autonomous-sql/" rel="noopener noreferrer"&gt;"Agentic AI Meets Database Development: What Changes When AI Can Actually Execute Queries"&lt;/a&gt; by Victor Horlenko, Head of AI Innovations at Devart, published on Unite.AI.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>database</category>
      <category>sql</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Testing a Free AI SQL Assistant Against a Real Schema: A Practical Workflow</title>
      <dc:creator>David Murray</dc:creator>
      <pubDate>Tue, 13 Oct 2026 09:19:19 +0000</pubDate>
      <link>https://dev.to/davidmurray/testing-a-free-ai-sql-assistant-against-a-real-schema-a-practical-workflow-fhj</link>
      <guid>https://dev.to/davidmurray/testing-a-free-ai-sql-assistant-against-a-real-schema-a-practical-workflow-fhj</guid>
      <description>&lt;p&gt;Generating SQL with AI is the easy part. Knowing whether the generated query is correct for your schema, your dialect and your business rules is where the time actually goes.&lt;/p&gt;

&lt;p&gt;This post walks through a repeatable workflow for evaluating AI-generated SQL, with the failure modes worth checking for. It closes with a look at the free Express edition of dbForge AI Assistant introduced in &lt;a href="https://www.devart.com/dbforge/" rel="noopener noreferrer"&gt;dbForge 2026.2&lt;/a&gt;, as one example of an assistant that works inside the IDE.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem: prompts are underspecified
&lt;/h2&gt;

&lt;p&gt;Take a typical request:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Total revenue per product category for last quarter, excluding cancelled orders.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Before any tool can answer that correctly, someone needs to resolve:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which table defines revenue: order lines, invoices or payments?&lt;/li&gt;
&lt;li&gt;Are refunds subtracted? Are discounts applied per line or per order?&lt;/li&gt;
&lt;li&gt;What are the quarter boundaries, and in which time zone?&lt;/li&gt;
&lt;li&gt;Which statuses count as cancelled?&lt;/li&gt;
&lt;li&gt;Which engine and version? Date functions and row limiting differ across SQL Server, MySQL and PostgreSQL.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the assistant only sees the prompt, it fills those gaps with assumptions. So step one is removing as many assumptions as you can.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Give the model real context
&lt;/h2&gt;

&lt;p&gt;Useful context includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Table and column names, plus keys and relationships&lt;/li&gt;
&lt;li&gt;The SQL dialect and version&lt;/li&gt;
&lt;li&gt;Business rules, for example "revenue = paid invoice lines minus refunds"&lt;/li&gt;
&lt;li&gt;The expected output shape: columns, grain, ordering&lt;/li&gt;
&lt;li&gt;Team conventions such as naming, formatting or CTE versus subquery preferences&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Drafts produced from this kind of input are much easier to review. Tools that read schema metadata directly save you from retyping the structure every time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Check the grain before the numbers
&lt;/h2&gt;

&lt;p&gt;The most common silent bug in generated SQL is row multiplication from a one-to-many join. Here is an illustrative example (written for this post, not output from any tool):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- Looks reasonable, but can inflate totals&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;customer_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="k"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;order_total&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;total_spent&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;customers&lt;/span&gt; &lt;span class="k"&gt;c&lt;/span&gt;
&lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;orders&lt;/span&gt; &lt;span class="n"&gt;o&lt;/span&gt;   &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;customer_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;customer_id&lt;/span&gt;
&lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;payments&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;order_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;order_id&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'paid'&lt;/span&gt;
&lt;span class="k"&gt;GROUP&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="k"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;customer_id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If an order can have more than one paid payment row, each &lt;code&gt;order_total&lt;/code&gt; is counted once per payment. The query runs fine and returns wrong numbers. A safer version checks the condition without changing the grain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;customer_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="k"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;order_total&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;total_spent&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;customers&lt;/span&gt; &lt;span class="k"&gt;c&lt;/span&gt;
&lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;orders&lt;/span&gt; &lt;span class="n"&gt;o&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;customer_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;customer_id&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="k"&gt;EXISTS&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;payments&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;
    &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;order_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;order_id&lt;/span&gt;
      &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'paid'&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;GROUP&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="k"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;customer_id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Whether this matches your definition of "paid" is a business decision, which is exactly why the reviewer, not the model, makes the call. Quick checks worth running on any generated aggregate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Compare &lt;code&gt;COUNT(*)&lt;/code&gt; with &lt;code&gt;COUNT(DISTINCT key)&lt;/code&gt; at each join stage&lt;/li&gt;
&lt;li&gt;Spot-check a handful of rows against a source you trust&lt;/li&gt;
&lt;li&gt;Look for filters on nullable columns that may drop valid rows&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 3: Ask for explanations and minimal fixes
&lt;/h2&gt;

&lt;p&gt;When something looks off, a targeted follow-up works better than "fix this":&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Here is the query, the error message, and the result I expected.
Dialect: PostgreSQL 16.
Explain what each join and filter does, then propose the
smallest change that produces the expected result, and explain it.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Minimal diffs are easier to review than full rewrites, and the explanation tells you whether the model understood the problem or just reshuffled the query.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Treat performance advice as a hypothesis
&lt;/h2&gt;

&lt;p&gt;Suggested rewrites and indexes are a starting point for investigation. Validate them like a colleague's suggestion:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Confirm the revised query returns the same rows as the original.&lt;/li&gt;
&lt;li&gt;Compare execution plans.&lt;/li&gt;
&lt;li&gt;Compare elapsed time and resource usage under the same conditions.&lt;/li&gt;
&lt;li&gt;For index suggestions, check whether an existing index already covers the predicate, and weigh the write and storage cost.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Step 5: Fence off writes
&lt;/h2&gt;

&lt;p&gt;Generated &lt;code&gt;UPDATE&lt;/code&gt;, &lt;code&gt;DELETE&lt;/code&gt; and DDL statements go to a test database first. Run them inside a transaction you can roll back, and review them like any pull request.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where an in-IDE assistant fits
&lt;/h2&gt;

&lt;p&gt;Every step above involves moving between a prompt, a database and an editor. An assistant inside the database tool removes some of that switching.&lt;/p&gt;

&lt;p&gt;dbForge 2026.2 introduced a free Express edition of &lt;a href="https://www.devart.com/dbforge/ai-assistant/" rel="noopener noreferrer"&gt;dbForge AI Assistant&lt;/a&gt;, which runs inside dbForge products rather than as a standalone app. The parts relevant to this workflow:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Schema context:&lt;/strong&gt; attach a database and the AI Assistant works with its metadata, such as schema and index information. Several databases can share one chat, and two scripted databases can be compared.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;File context:&lt;/strong&gt; attach application code, database projects, diagrams, sample SQL or custom instructions, and optionally auto-attach the document you are editing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Editor round trip:&lt;/strong&gt; generated SQL moves into the SQL editor, where you test it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Capabilities:&lt;/strong&gt; generating, explaining, fixing and optimizing SQL, plus questions about SQL and dbForge features.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Engines:&lt;/strong&gt; SQL Server, MySQL, MariaDB, Oracle, PostgreSQL and cloud services based on them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Model choice:&lt;/strong&gt; Anthropic and OpenAI models can be selected under &lt;strong&gt;Tools &amp;gt; Options &amp;gt; AI Assistant &amp;gt; General&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Express edition has a limited token allowance and keeps chats for 14 days. Paid plans raise the allowance and remove the history limit.&lt;/p&gt;

&lt;p&gt;A sensible evaluation: run Steps 1 through 5 against a query you have already debugged, and see whether in-tool context shortens the loop for your schema.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;AI makes first drafts cheap. Correctness still comes from context, grain checks, minimal diffs, measured performance and careful handling of writes. Build those habits once and they carry over to whichever assistant you end up using.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Based on The AI Journal, &lt;a href="https://aijourn.com/free-ai-sql-assistant-is-now-available-in-dbforge-2026-2/" rel="noopener noreferrer"&gt;"Free AI SQL Assistant Is Now Available in dbForge 2026.2"&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>sql</category>
      <category>database</category>
      <category>ai</category>
      <category>productivity</category>
    </item>
    <item>
      <title>dbForge AI Assistant: A Developer's Tour of What It Actually Does</title>
      <dc:creator>David Murray</dc:creator>
      <pubDate>Mon, 21 Sep 2026 17:21:15 +0000</pubDate>
      <link>https://dev.to/davidmurray/dbforge-ai-assistant-a-developers-tour-of-what-itactually-does-5h7</link>
      <guid>https://dev.to/davidmurray/dbforge-ai-assistant-a-developers-tour-of-what-itactually-does-5h7</guid>
      <description>&lt;p&gt;Every database tool ships an AI assistant now, and most of the marketing sounds identical: plain English in, SQL out. That's the easy part. The more useful question for anyone actually deciding&lt;br&gt;
whether to turn one on is what it does once you're past the first demo query, across a real editing session, on a real schema, in whatever database engine you're actually using.&lt;a href="https://www.devart.com/dbforge/ai-assistant/" rel="noopener noreferrer"&gt;dbForge AI Assistant&lt;/a&gt;, built into dbForge Studio for SQL Server and the rest of the dbForge product line,&lt;br&gt;
is worth a proper walk-through for exactly that reason. Here's what it covers, feature by feature.&lt;/p&gt;

&lt;h2&gt;
  
  
  Plain English to working SQL
&lt;/h2&gt;

&lt;p&gt;The core loop is text to SQL. Attach a database, describe what you want in a sentence, and the assistant returns valid SQL mapped to your actual schema, not a generic template. Because the&lt;br&gt;
schema is attached rather than pasted in as context, the same request against two different databases returns two different, correctly scoped queries. This is the baseline capability, and it's also the one most AI SQL tools advertise. What differentiates a database-native assistant from a general chatbot is everything below.&lt;/p&gt;

&lt;h2&gt;
  
  
  Optimizing and troubleshooting queries
&lt;/h2&gt;

&lt;p&gt;Correct SQL and fast SQL are not the same thing, and this is where database context starts to matter.&lt;br&gt;
Paste in a query and the assistant returns an optimized version along with practical suggestions, flagging inefficient indexes and pointing at concrete ways to improve execution rather than generic&lt;br&gt;
textbook advice.&lt;br&gt;
A recent hands-on demo from IT educator Frank, who runs the YouTube channel Learning and Technology with Frank, shows this in practice with a 2026.1 update that has the assistant read a database's actual index metadata, the B-tree and unique indexes underneath the schema, before it recommends a rewrite. He attached a copy of Microsoft's AdventureWorks sample database, ran a generated query, asked the assistant to optimize it, and got back a rewrite that used indexes already present rather than suggesting new ones blind. It's a useful illustration of what context-aware optimization means in practice: recommendations grounded in indexes that actually exist, not ones that might.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fixing and explaining SQL
&lt;/h2&gt;

&lt;p&gt;Two related, everyday capabilities: error detection with auto-fix, and clause-by-clause explanation. The first spots issues in a query and returns a corrected version you can run immediately. The second&lt;br&gt;
breaks down what a query does and how it produces its results, in plain language.&lt;br&gt;
Both are aimed less at greenfield work and more at the SQL you inherited: the two-hundred-line stored procedure with no comments, the query a former teammate wrote two years ago that nobody fully&lt;br&gt;
trusts. Paste it in, ask what it does, get a walkthrough instead of an afternoon of manual tracing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Beyond single queries
&lt;/h2&gt;

&lt;p&gt;The advanced feature set covers the parts of database work that sit around query writing rather than inside it: AI-powered formatting and style enforcement for consistent SQL across a team, generation of&lt;br&gt;
stored procedures and functions from a prompt, AI-assisted unit testing that generates tests for database objects with comments explaining how each one works, transaction and error-handling&lt;br&gt;
recommendations to prevent deadlocks and missed rollbacks, and reusable snippets you can insert from the context menu. None of these are headline features on their own, but together they cover a meaningfully larger share of routine database work than text-to-SQL alone.&lt;/p&gt;

&lt;h2&gt;
  
  
  AI chat, for when you have a question
&lt;/h2&gt;

&lt;p&gt;Separate from any specific query, the assistant answers general SQL questions and questions about the dbForge product itself, in real time, without leaving the editor. Useful for the kind of question that would otherwise mean a tab switch to a search engine or a forum.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where it runs, and what it sends
&lt;/h2&gt;

&lt;p&gt;dbForge AI Assistant works across SQL Server, MySQL and MariaDB, Oracle and PostgreSQL, and runs inside compatible dbForge products, including dbForge Studio for SQL Server and the other engine-specific Studios, dbForge Edge, and a range of standalone dbForge tools. The same capability set applies regardless of which supported engine you're attached to.&lt;br&gt;
Worth knowing if you're evaluating it for a team with data governance requirements: the assistant sends database metadata for context, not the actual data in your tables, and only your conversation is stored&lt;br&gt;
on the server. Conversations are not used for model training. It's off by default in any dbForge product and has to be explicitly enabled.&lt;/p&gt;

&lt;p&gt;If you're deciding whether to turn on an AI assistant inside your database tool, that's the right frame: does it ground its answers in your actual schema and indexes, across the engines you actually use,&lt;br&gt;
and does it explain itself well enough that you're learning something, not just accepting output. dbForge AI Assistant works across the four major engines from inside the &lt;a href="https://www.devart.com/dbforge-studio.html" rel="noopener noreferrer"&gt;dbForge Studios&lt;/a&gt; and the other&lt;a href="https://www.devart.com/dbforge/" rel="noopener noreferrer"&gt;dbForge&lt;/a&gt; tools most SQL Server, MySQL, Oracle and PostgreSQL developers already have open,&lt;br&gt;
which is worth a look if that's what you're weighing&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Source&lt;/strong&gt;: “Index-Aware AI SQL Optimization in dbForge 2026.1”, Learning and Technology with Frank. Watch: &lt;a href="https://www.youtube.com/watch?v=BMFCbA-T764" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=BMFCbA-T764&lt;/a&gt;. &lt;/p&gt;

</description>
      <category>ai</category>
      <category>database</category>
      <category>dataengineering</category>
      <category>sql</category>
    </item>
    <item>
      <title>Stop Sending Every SQL Query to Your Most Expensive Model — Build a Router Instead</title>
      <dc:creator>David Murray</dc:creator>
      <pubDate>Tue, 15 Sep 2026 09:52:08 +0000</pubDate>
      <link>https://dev.to/davidmurray/stop-sending-every-sql-query-to-your-most-expensive-model-build-a-router-instead-2ij3</link>
      <guid>https://dev.to/davidmurray/stop-sending-every-sql-query-to-your-most-expensive-model-build-a-router-instead-2ij3</guid>
      <description>&lt;p&gt;If you've built or integrated an AI SQL assistant into your stack, you've likely hit this wall: it works great in the demo, it works great in week one, and then usage scales and the model API bill scales right alongside it. The default fix — swap in a cheaper model everywhere — usually just trades your cost problem for a quality problem.&lt;/p&gt;

&lt;p&gt;The better fix is architectural: route each query to the model tier its actual complexity requires.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why one model tier doesn't work
&lt;/h2&gt;

&lt;p&gt;SQL queries vary wildly in the reasoning they require. &lt;code&gt;SELECT * FROM users WHERE id = 4471&lt;/code&gt; and a cross-schema retention analysis using window functions are both "SQL," but they're not remotely equivalent workloads. Routing both through a frontier model is expensive overkill for the first one.&lt;/p&gt;

&lt;p&gt;A practical tiering scheme:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tier&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;th&gt;Examples&lt;/th&gt;
&lt;th&gt;Model needed&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1 — Routine&lt;/td&gt;
&lt;td&gt;Simple, well-defined&lt;/td&gt;
&lt;td&gt;SELECTs, lookups, basic CRUD, syntax fixes&lt;/td&gt;
&lt;td&gt;Fast, low-cost model&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2 — Moderate&lt;/td&gt;
&lt;td&gt;Multi-step reasoning&lt;/td&gt;
&lt;td&gt;Joins, subqueries, aggregations, optimization hints&lt;/td&gt;
&lt;td&gt;Mid-tier model&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3 — Complex&lt;/td&gt;
&lt;td&gt;Deep schema reasoning&lt;/td&gt;
&lt;td&gt;Cross-DB queries, window functions, execution-plan tuning, schema refactoring&lt;/td&gt;
&lt;td&gt;Frontier model&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Benchmarked figures put Tier 1 around $0.001/query versus roughly $0.03/query for a frontier model — a gap that scales linearly with volume. Tier 3 queries also need injected context (table relationships, foreign keys, indexes, dialect-specific syntax), which is expensive to carry through every request regardless of tier.&lt;/p&gt;

&lt;h2&gt;
  
  
  The pipeline: classify → route → execute → validate
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Classification
&lt;/h3&gt;

&lt;p&gt;This is the stage that determines whether the whole system works. Three implementation options:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rule-based (regex/AST)&lt;/strong&gt;: Detect structural signals — table count, join depth, presence of window functions or subqueries. Fast, deterministic, zero model overhead. Handles the obvious cases well.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lightweight classifier model&lt;/strong&gt;: A small model trained specifically to estimate SQL complexity. Costs a fraction of a cent per call, which easily justifies itself by avoiding unnecessary frontier-model invocations. Can often run locally. Also useful for classifying natural-language prompts before SQL generation even happens.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hybrid&lt;/strong&gt;: Rules catch the clear cases for free; the classifier handles the ambiguous middle where structure alone doesn't tell you enough. This is the practical sweet spot for most teams.&lt;/p&gt;

&lt;h3&gt;
  
  
  Routing
&lt;/h3&gt;

&lt;p&gt;Beyond tier, routing decisions should also account for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Schema context requirements&lt;/strong&gt; — queries needing foreign key/index awareness typically need a higher-capability model regardless of surface complexity.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Latency tolerance&lt;/strong&gt; — autocomplete and inline suggestions have tight budgets; background jobs don't.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Classifier confidence&lt;/strong&gt; — low confidence should bias toward routing up. A bad downgrade often triggers a retry, and retries are more expensive than getting it right the first time.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Validation
&lt;/h3&gt;

&lt;p&gt;Post-execution checks confirm syntax correctness, sane result shapes, and schema consistency. Failures trigger escalation and a rerun at a higher tier.&lt;/p&gt;

&lt;h2&gt;
  
  
  A real implementation detail worth knowing
&lt;/h2&gt;

&lt;p&gt;While building schema-aware capabilities into Devart's &lt;a href="https://www.devart.com/dbforge/ai-assistant/" rel="noopener noreferrer"&gt;dbForge AI Assistant&lt;/a&gt;, the team found that classification accuracy depended heavily on schema context — not just query structure. Queries with ambiguous table names or implicit relationships were reliably misclassified as simple and sent to models that couldn't actually resolve them correctly. The fix: feed the classifier schema metadata alongside the query itself, not just the syntax tree.&lt;/p&gt;

&lt;h2&gt;
  
  
  Metrics that tell you if the routing is actually working
&lt;/h2&gt;

&lt;p&gt;Don't just track average cost — it hides problems.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Cost per query, by tier.&lt;/strong&gt; A blended average can look fine while masking a system that's routing 50% of queries to the wrong tier.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Escalation rate.&lt;/strong&gt; The percentage of Tier 1/2 outputs that fail validation and need rerouting. Keep it under 5%; above that, retrain the classifier or give it more schema context.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Latency impact.&lt;/strong&gt; Classification and routing overhead should add no more than 50–100ms.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Watch for the escalation tax: a misrouted query means a classifier call + initial model call + failed validation + reroute + second model call. Stack enough of those and you can end up paying more than if you'd just routed to the frontier model directly. Track escalation rate alongside cost per call, not in isolation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the ROI ceiling sits
&lt;/h2&gt;

&lt;p&gt;Well-tuned routing reportedly delivers 40–60% inference cost reduction while keeping escalation under 5% and preserving quality on complex queries. Pushing past that generally requires self-hosting smaller models for Tier 1 traffic — workable, but it adds real operational overhead (infra, monitoring, model lifecycle) that not every team needs to take on.&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR for implementation
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Build the classifier before you finalize the model lineup — it's the highest-leverage piece.&lt;/li&gt;
&lt;li&gt;A hybrid classifier (rules + lightweight model) gets you most of the savings without excess complexity.&lt;/li&gt;
&lt;li&gt;Feed the classifier schema metadata, not just query syntax — this matters more than it looks like it should.&lt;/li&gt;
&lt;li&gt;Design validation logic before you lock in classification thresholds.&lt;/li&gt;
&lt;li&gt;Track escalation rate as your primary quality signal.&lt;/li&gt;
&lt;li&gt;As local inference gets cheaper, the payoff from correct tiering only grows — the cost gap between tiers widens, not shrinks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;This piece draws on an original analysis published on &lt;a href="https://www.unite.ai/ai-sql-query-routing-cost-optimization/" rel="noopener noreferrer"&gt;Unite.AI&lt;/a&gt; by Victor Horlenko, Head of AI Innovations at Devart.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>database</category>
      <category>sql</category>
      <category>architecture</category>
    </item>
  </channel>
</rss>
