Xata’s branching system uses Copy-on-Write (CoW) at the storage layer to create instant database branches. The child branch contains the exact schema and data of the parent branch at the moment of branch creation. After creation, branches are independent PostgreSQL instances: modifying the data in the child branch doesn’t affect the parent branch, nor the other way around. The typical use-cases of branching include ephemeral environments, preview databases, or ad-hoc testing. You can also use branches as a convenient way to “freeze” the data in time, or to have a quick data rollback mechanism.Documentation Index
Fetch the complete documentation index at: https://xata.io/docs/llms.txt
Use this file to discover all available pages before exploring further.
How it works
When a branching operation is started, the first step is to create a Copy-on-Write snapshot of the underlying logical volume. This is done at the storage level. A new PostgreSQL instance is started on a logical volume that is initialized from this Copy-on-Write snapshot. Because the mechanism lives entirely below PostgreSQL, Xata doesn’t require any modifications to the PostgreSQL source code. Therefore, we run vanilla Postgres and can support any extension.Copy-on-Write
In generic terms, Copy-on-Write is a mechanism used to share data efficiently between processes. Instead of copying data right away when multiple programs use it, the same data is shared between programs until one tries to modify it. When stored on disk, the database volume is split into blocks. In the illustration below, the blocks are numbered from 1 to 8. Because we’re using a distributed storage system, the blocks can be on different disks and nodes. A metadata index is used to keep track where the data blocks are stored.

