How we built an AI agent you can trust with your production tables ClickHouse announced Schema Advisor, its first end-to-end AI-assisted schema-change experience for ClickHouse Cloud, now in Private Preview. The tool guides users from recommendation through impact analysis to deployment, using deterministic tests to generate recommendations and LLMs only to plan changes, which a durable workflow then validates and applies. ClickHouse said early LLM-only prototyping produced hallucinations such as nonexistent syntax like "ALTER TABLE ... MODIFY PRIMARY KEY" and wrong diagnostic queries that drove unnecessary compute spend. 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. The problem: schema changes can be high impact and high risk but also high reward 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 https://clickhouse.com/docs/guides/clickhouse/data-modelling/sparse-primary-indexes the-primary-index-has-one-entry-per-granule . 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. Ways to solve 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. The flow, end to end Demonstration 1. 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 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. What makes it trustworthy To make sure our users have high confidence in trusting Schema Advisor, we included these design approaches. 1. 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. 2. 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. 3. AI never executes the SQL. We use Temporal https://temporal.io 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. 4. 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. Trust under the hood 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. 1. Tracing for self-improvement: We manage our agent skills via Langfuse’s skill manager https://langfuse.com/docs/skill-management/overview 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. 2. 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. Limitations 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 How to access it Sign up for the waitlist in the ClickHouse Cloud UI under the Previews page on Organization settings https://clickhouse.com/docs/products/cloud/features/self-service-previews . For more information, check out our documentation https://clickhouse.com/docs/products/cloud/features/ai-ml/schema-advisor . We are excited to give you access and get your thoughts 🙂