Git for Your Database: PolarDB Lets Agents Experiment Safely
By Wang Kang
LLM applications are moving from Chatbots to Agents. A Chatbot understands a question, retrieves information, and generates an answer. An Agent goes further: it breaks the job down, invokes tools, reads data, executes operations, checks the results, and adjusts its strategy based on what comes back. That shift changes what the database has to do inside an Agent system.
The database used to hold business data and final results. Now it also has to carry an Agent's task status, intermediate data, experiment results, and execution history — and often becomes the workspace where the Agent does its work directly.
1. When an Agent Has to Modify the Database Directly
More and more scenarios require Agents to access — and even modify — the database directly. We want a Coding Agent that doesn't just write code but validates data and schema changes against real data shapes. We want customer service or order Agents that create orders and update their status automatically. We want data analytics Agents that run complex, multi-round iterative analysis over real business data. Nearly every Agentic scenario that actually ships today needs AI to modify data itself — it may well get it right, but it will certainly also make mistakes. That's the tension: AI needs a place where it can experiment freely, and production data is exactly the place where you cannot afford mistakes.
Here is a concrete case. A game team wants several Agents to evaluate different operations strategies against real business data. Each Agent needs a copy of the live business data that is identical to production, so it can actually write its strategy in, run a simulation, and see how retention and spending move. Good results get adopted, bad ones are discarded outright — and no Agent can ever be allowed to touch production data.
2. What Do We Actually Need, and Why Traditional Approaches Fall Short
What we want is easy to describe. Every Agent gets its own data space, filled with complete, real data that matches production. It can read and write freely and break whatever it likes. Its writes stay invisible to production and to every other Agent. When it's done, you throw the space away and leave no cleanup debt behind. Many Agents work at the same time, each on its own, without stepping on one another.
A traditional database gives you a few options:
• Restore a new instance from backup: spin up a separate instance for each Agent through backup and restore. This approach has several problems. It is slow to provision — copying the backup and replaying logs eats a lot of time, and the Agent just waits. It is heavy on O&M — you start the instance, configure the network, configure accounts, and so on. And it is expensive, because every instance carries its own compute and its own full copy of the data.
• Copy databases and tables inside the current instance: this removes the O&M and usage cost of separate instances, but it still copies the data in full, so it is still slow and consumes several times the space. Copying a large table also drives heavy I/O for a short window, which can hit live workloads.
As data volumes grow and the number of Agents increases, these drawbacks quickly become untenable. Clearly, what AI really needs is an easy-to-use, instantly created, low-cost disposable sandbox.
3. How PolarDB Branch Solves It
PolarDB Branch answers exactly that need: a single SQL statement creates an isolated space inside your current instance in seconds — one that takes no extra storage and can be discarded at any time.
First, run CREATE BRANCH on the current instance to derive one or more branches. It finishes in seconds no matter how large the source database is. A branch copies no data at creation time and takes no extra space; it splits off its own data only as changes accumulate.
CREATE BRANCH agent_a; -- Derive a branch containing all current databases
CREATE BRANCH agent_b WITH DATABASE orders; -- Or fork only the specified database
Next, each Agent switches into its own branch with SET branch — no new connection, no endpoint switch, no different account. From then on every SQL statement lands on that branch. Database and table names stay the same, and the application notices nothing:
SET branch = 'agent_a';
USE app_db;
UPDATE users SET status = 'test' WHERE id < 100; -- Affects only the agent_a branch
ALTER TABLE orders ADD COLUMN risk_score INT; -- DDL also affects only agent_a
Finally, one command cleans everything up when you're done:
DROP BRANCH agent_a;
The diagram below shows what Branch feels like in practice: inside a single instance, Agents with different goals each work from their own view and see their own independent data.

Back to the game operations-strategy scenario above. With Branch, each Agent creates its own branch and is ready in seconds, while copy-on-write lets them all share the same real player data underneath. The branches take almost no extra space at first; only the campaign configuration, segmentation, and simulated payouts written by each Agent are stored against its own branch. Different strategies run truly in parallel on different branches, with writes fenced from each other and completely invisible to production. When the runs finish, you compare the retention and spending curves, pick the best strategy, and delete the branches — no cleanup debt left behind.
Do the math. Say your AI Agent platform runs 50 concurrent Agents, and each one needs its own sandbox over a production database of 1 TB. The gap between the traditional approach and Branch is an order of magnitude:

4. How PolarDB Branch Works

PolarDB Branch delivers "seconds, isolated, zero intrusion" through one plain idea: copy data as needed instead of up front. It is implemented in three layers, each with a distinct design goal:
1. Namespace layer: change the name, not the code. After SET branch = 'agent_a', logical database names are mapped to the physical database names of that branch. Database and table names stay exactly as the application expects, so not a single character of application SQL changes. CREATE BRANCH is essentially a point-in-time consistent batch derivation of the tables inside the target databases.
2. Data layer: share, then copy-on-write (COW). Creating a branch copies no data at all; the branch and the source database share the same physical storage. That's why derivation takes seconds and costs almost no extra space at the start. Reads of untouched data go straight to the shared copy in the source database, and only a write produces the branch's own copy, made just before the change.
3. Version storage layermaintained independently, with zero intrusion into the source database. A separate Page Version Store (PVS) storage engine manages a branch's historical data. The source database has to cooperate in exactly one way: before a page is modified, hand over its old version. Everything else reads and writes as usual. This keeps the complexity contained within the buffer pool and the I/O path, so it never spreads into transactions, DDL, replication, or other subsystems.
5. Fork: Exposing the Underlying Capability on Its Own
If you don't need the Branch abstraction and just want a fast copy of a database or table, along the lines of CREATE TABLE ... LIKE, you can use the COW layer beneath PolarDB Branch directly and copy databases and tables in seconds. We provide a Fork statement that targets an individual database or table.
-- Fork a table
CREATE TABLE t1_dev FORK FROM TABLE t1;
-- Fork a database
CREATE DATABASE app_dev FORK FROM DATABASE app;
From the user's point of view, as soon as the statement returns, table t1_dev and database app_dev are independently readable and writable, just like any ordinary database or table.
6. Closing Thoughts
As AI starts to act on the world for real, we have no choice but to put it in front of production data. Either we tie its hands with read-only permission, or we let it loose and hold our breath through every hallucination. The freedom to experiment and the safety of production should no longer be an either-or choice. PolarDB Branch is the foundation we want to lay for this era — so intelligence can grow both boldly and safely.
Read previous post:
Comments
Related Products
-
Qoder
From Assisted to Autonomous — Adapting to Every Programming Need
Learn More -
QwenWork
QwenWork is dedicated to helping employees strengthen their professional competitiveness in the AI era and to enabling enterprises to improve organizational effectiveness.
Learn More -
Token Plan
Build more, spend less. One plan, every modality.
Learn More -
PolarDB for PostgreSQL
Alibaba Cloud PolarDB for PostgreSQL is an in-house relational database service 100% compatible with PostgreSQL and highly compatible with the Oracle syntax.
Learn More
More Posts by ApsaraDB
- AI Coding Context Keeps Getting More Expensive — Tair Built a Capability for That, and We Want You to Test It
- With PostgreSQL Firmly in Place as the Data Foundation, What Else Do Agents Need to Truly Run?
- The 6 Components of RAG, Actually Just Need 1 Database
- PolarDB-X Zero: Get an AI-Friendly Database in 30 Seconds with a Single Command
- HiCache Across Multi‑Parallelism and Distributed Serving
- How CXL 2.0 Drives the Evolution of PolarDB's Software-Hardware Co-Designed Architecture
- CloudJump III: Optimizing Cloud Databases for Tiered Storage (SIGMOD 2026)
- Highlights | Alibaba Cloud Database New Features in September 2026
- [Infographic] Highlights | Database New Features in August 2026