Dev48
Language
  • About
  • Services
  • Industries
  • Technologies
  • Articles
  • Contacts
Book a call
    Home/Articles/How we built an ai agent you can trust with your production tables
Dev48
info@dev48.org+375 29 320-40-96WhatsApp@isky_by

© 2026 · All rights reserved.

How we built an AI agent you can trust with your production tables

Source: ClickHouse•December 1, 2026 at 12:39 AM

How we built an AI agent you can trust with your production tables

Schema Advisor guides you from recommendation to impact analysis to deployment, with trust built into the entire workflow.

If you have been working on databases for a while, you know schema changes are a fact of life. Whether you're improving an existing workload or adding a new use case, your schema could change as often as your data. But how do you know which changes matter, and when do you actually need to make the change? How do you roll them out without any downtime?

In ClickHouse, the schema has a heavy influence on performance, especially because the schema dictates how your data is stored, from your primary key to your compression. Your schema matters a lot in ClickHouse.

Today we are announcing ClickHouse Cloud's first end-to-end AI-assisted experience for making those changes: Schema Advisor, now in Private Preview. Schema Advisor guides you from recommendation → impact analysis → deployment, with trust embedded throughout the workflow. It’s an AI experience you can rely on, regardless of your level of ClickHouse expertise.

Getting the schema right is one of the highest leverage things you can do in ClickHouse. A better ORDER BY can turn a full table scan into reading a handful of granules. The right compression can cut your storage bill. But for anyone who has had to do it, it’s often easier said than actually prioritized and executed. To do this properly, you need to:

  • Figure out what can be improved.
  • Test and validate your hypothesis.
  • Deploy the changes with zero downtime in production.

But this takes time and sometimes tech debt is difficult to prioritize over feature development. And none of these steps can be compromised.

What can we do to make the experience better for ClickHouse users?

Option 1: Use AI. Agents would be the obvious choice - have LLMs generate the recommendation and then apply the change. This ensures we can support any schema changes because it doesn’t require us to explicitly map out every different schema change possible. But in our early prototyping, we found how easy it was for an LLM to hallucinate when recommending a schema change. The agent might suggest syntax that doesn’t actually exist (ALTER TABLE ... MODIFY PRIMARY KEY was one of them) or execute the wrong diagnostic query resulting in unnecessary compute spend. What’s worse is depending on your level of ClickHouse knowledge, you might not catch it before the damage is done 😱

Option 2: Deploy the schema change for you. Alternatively we can also help our users by building a deployment flow, much like the generic schema migration tools out there. Users would have to tell us the SQL and have us apply it. It’s familiar and deterministic. But it assumes you already know the exact change you want and how to execute it. The issue we have found with generic tooling is there’s no way for them to take into account all the different ways ClickHouse might work and might miss impactful nuances.

Separately, these options have gaps. AI could potentially hallucinate. Deployment helps the user execute but provides no judgement or understanding of ClickHouse. What our users need is a full end to end flow that supports them on the part of schema migration that they don’t have a good process for, regardless of their skill level.

That’s how we ended up building Schema Advisor where deterministic tests generate the recommendations, LLMs figure out the plan to make the change, and then hands the plan over to a durable workflow to prove it and apply it. LLM for the plan. Trusted and tested workflow execution for everything else.

  • You can start Schema Advisor from a recommendation via the Tables page under Monitoring. We tell you what the recommendation is and what queries drove that recommendation.

From there, you can go to impact analysis (recommendation) or skip straight to deployment.

  • Impact analysis. AI builds a plan with the exact SQL for every step. Then you can either execute the benchmarking in the service you're already in or execute it in an isolated sandbox. We take a sample of your table as the baseline table (your current schema) and build a candidate table (the new one) from it. Then we replay the queries that run most often on your table against both and compare query time, rows scanned, and data read, averaged across the queries. You can see how those queries perform on the current schema vs. the new one.
  • Deployment. For this step, we guide you into deploying the change into production. How we execute this step depends on your type of schema change. Full table rebuild: These are schema changes that require a full table rebuild. This would include modifying the sort order or primary key. We will create the new table, migrate the data, audit to validate, and then execute EXCHANGE TABLES with the production table so there’s zero downtime. The old table is stored as the backup. Alter table: These are schema changes that can be applied directly to your production table. This would include things like creating indexes and projections. There’s no rebuild needed, so Schema Advisor shows you the exact ALTER statement and, once you approve it, applies the change directly to your production table.
  • Full table rebuild: These are schema changes that require a full table rebuild. This would include modifying the sort order or primary key. We will create the new table, migrate the data, audit to validate, and then execute EXCHANGE TABLES with the production table so there’s zero downtime. The old table is stored as the backup.
  • Alter table: These are schema changes that can be applied directly to your production table. This would include things like creating indexes and projections. There’s no rebuild needed, so Schema Advisor shows you the exact ALTER statement and, once you approve it, applies the change directly to your production table.

Throughout this process - you stay in control as the human in the loop to approve each step before moving on to the next one. If the results show the change isn't worth making, you can dismiss the recommendation.

To make sure our users have high confidence in trusting Schema Advisor, we included these design approaches.

  • Recommendations aren’t AI: Recommendations are created by deterministic tests run in the background on your query logs to ensure trust and consistency across organizations. No hallucinations here. From those tests, we can generate a recommendation on how to optimize your table schema. These tests are made with no impact to your compute resources.
  • Showing the proof: Just as your math teacher always wanted, every recommendation has proof to show what the change is and how impactful the change can be.
  • AI never executes the SQL. We use Temporal to execute the plan to ensure no AI can ever hallucinate. This ensures safety, the ability to retry, and real-time monitoring. The only steps that effect production directly, like EXCHANGE TABLES or DROP TABLE, are templated SQL run by the workflow and never the LLM. They only run when you approve them, with the exact statement shown. That includes dropping the old table after a rebuild, which only happens when you click the cleanup button.
  • Workload isolation: As with software engineering best practices, you want to test somewhere outside of production. We offer you the ability to either run impact analysis in the service you’re in or a completely isolated, ephemeral service made from your last backup (this requires backups to be set up). This allows us to execute impact analysis without touching your live table and minimize the permissions required to execute.

Now trust is not just in the user facing process but also how we ensure what’s under the hood is just as great as what’s in the cabin.

  • Tracing for self-improvement: We manage our agent skills via Langfuse’s skill manager and every agent action is traced in Langfuse. So when a session looks off, we can debug and see why. This also allows us to continuously improve our agent skills and run evals to make sure it’s up to our standard.
  • Inference gateway: Every model call Schema Advisor makes goes through the ClickHouse Inference Gateway, built on top of Amazon Bedrock. Bedrock gives us access to a wide range of LLMs on a service built for enterprise. This allows us to change LLMs as needed and pick the right one for each job. Your data stays within AWS’s security and privacy controls, and we layer our own safeguards on top.

There are some limitations to be noted in our Private Preview stage, and features may change as we learn from early users. We do not support (yet):

  • Deployment of full table rebuild changes (like changing the sort order or primary key) on tables that have continuous ingestion or are large. Plan and impact analysis are still supported, and changes applied directly with ALTER TABLE, like adding an index or projection, aren't affected by these limits.
  • Deployment of full table rebuild changes on tables with downstream dependencies, including materialized views
← All articles

What this article says

More in Data & Analytics

All →
You shouldn’t roll out your own billing system, but we did it anyway
Mixpanel

You shouldn’t roll out your own billing system, but we did it anyway

The engineering skill points game
Mixpanel

The engineering skill points game

ClickHouse announcements at AWS re:Invent 2026
ClickHouse

ClickHouse announcements at AWS re:Invent 2026

Fewer round trips, faster reads: client-side caching in go-redis
Redis

Fewer round trips, faster reads: client-side caching in go-redis

Apache Iceberg Tables: How They're Built, Created and Maintained
Starburst

Apache Iceberg Tables: How They're Built, Created and Maintained

How agents are reshaping software engineering
Google Analytics

How agents are reshaping software engineering

More from ClickHouse

ClickHouse announcements at AWS re:Invent 2026
ClickHouse

ClickHouse announcements at AWS re:Invent 2026

What is ClickHouse Security? A technical overview of the agentic SIEM built on ClickHouse
ClickHouse

What is ClickHouse Security? A technical overview of the agentic SIEM built on ClickHouse

Hints and hazards: pg_plan_advice in PG19
ClickHouse

Hints and hazards: pg_plan_advice in PG19

Durable and auditable workflows with DBOS and ClickHouse Managed Postgres
ClickHouse

Durable and auditable workflows with DBOS and ClickHouse Managed Postgres

Your agents don't care that you're a batch shop
ClickHouse

Your agents don't care that you're a batch shop

ClickHouse expands AWS strategic collaboration with a $1.5 billion-plus agreement to scale its unified enterprise AI data stack
ClickHouse

ClickHouse expands AWS strategic collaboration with a $1.5 billion-plus agreement to scale its unified enterprise AI data stack