The instant database scratchpad: xata scratch

tudorg2 pts0 comments

The instant database scratchpad: xata scratch | xata

11.9k<br>11.9kLog inGet Started

Back to Blog<br>The instant database scratchpad: xata scratch<br>xata scratch gives you a disposable copy of your Postgres from the terminal. One command forks a branch with your real data, runs your query, and deletes it.

By:<br>Divyendu Singh<br>Published:<br>Jul 17, 2026<br>Reading time:<br>2 min read

Back to Blog<br>Tags<br>Xata

Featured<br>A thousand Postgres branches for $1Inside Xatastor: ZFS + NVMe-oF for Postgres databasesIntroducing Xata OSS: Postgres platform with branching

Previously we have explored what workflows can we unlock, if database branches were easy, cost effective (1000 branches for $1) and fast (1-2 second boot time).<br>One workflow it opens up is “scratch pad for database”. A single command that allows your to run one-off experiments against production using an isolated instant database branch that is automatically deleted once the task is done.<br>TL;DR; (on an initialized project)<br>xata scratch -x "SELECT FROM " to isolate one off heavy analytical queries on copy of production data without competing on resources with production traffic.<br>OR<br>xata scratch -x "SELECT " to check the performance of a query you want to optimize on realistic data<br>OR<br>xata scratch psql a single command to create a branch and drop into any binary like psql, pgcli or even a custom one, as long as it supports the standard Postgres environment variables.<br>OR<br>xata scratch<br>OR<br>xata scratch<br>Here you can see it in action:

Under the hood<br>Under the hood, xata scratch command doesn’t do anything fancy, it simply creates ephemeral branches by<br>calls our create branch API which is fast by default<br>we call it with sane parameters like scale to zero enabled<br>wake up time is also around a second

it injects known / common environment variables into the subprocess<br>it calls either an inline query or a binary

as the subprocess returns, it terminates the scratch / child branch<br>profit, that’s all it needs to create a database scratchpad via ephemeral database branches<br>As you can see the command itself is straightforward. What makes it possible is an architecture where creating and deleting database branches is so fast and cheap that they can be treated as disposable resources.<br>More to come<br>Having access to instant and cost effective database branches opens up workflows which were previously unimaginable. We are exploring the frontier of developer experience we can provide with the end goal of saving costs (productivity, lower CI times) and increasing confidence (realistic data makes developing complicated features easier, think preview branches but with realistic data).<br>Try it out<br>You can try all this today by simply signing up  and starting a new project on Xata. If you have any questions or interesting use-cases, please don’t hesitate to reach out.<br>A scratch buffer for your Postgres

*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2 [&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none">Copy as Markdown

Share

Give every agentic workload its own Postgres branch<br>Create instant database clones with production-like data for every agent, workflow, and CI/CD pipeline.

Get started now

Share

Give every agentic workload its own Postgres branch<br>Create instant database clones with production-like data for every agent, workflow, and CI/CD pipeline.

Get started now

Related Posts

Database branching for AI coding agents: a minimal, CLI-first setup that actually works

Learn how to enable database branching for coding agents like Claude Code and Amp Code using simple Xata CLI instructions in AGENTS.md. No complex skills required.

Every AI agent needs a database it can break

AI agents need two infrastructure layers: real-time streaming for fresh data and database branching for sandboxes. How to build both with Postgres.

Teaching Claude Code to use isolated database branches with Agent Skills

Learn how to set up the Xata Agent Skill in minutes. Enable Claude Code to access realistic data using isolated database branches for safer, faster debugging.

From DBA to DB Agents

Discover how a PostgreSQL DBA’s decade of expertise evolved into designing Xata’s AI-powered Postgres agent, automating monitoring and observability.

database xata scratch data postgres branches

Related Articles