Skip to main content
A branch is a running Postgres database. Creating one copies the data of its parent, and the branch checked out in this folder is the one commands act on when no branch is given. Every command below also takes -h, --help.

list

List all branches
string
Organization ID
string
Project ID
string
Branch ID
boolean
default:"false"
Output in JSON format
string
The profile to use
Aliases: xata branch ls

describe

Describe a branch
string
Organization ID
string
Project ID
string
Branch ID
boolean
default:"false"
Output in JSON format
string
The profile to use
string
The branch to describe
Aliases: xata branch view, xata branch show

create

Create a new branch A branch is a running Postgres database that starts as a copy of its parent. It takes a moment to come up, so xata branch wait-ready is what to run before connecting to it. It is checked out afterwards when this folder already has an organization, project and branch to work from.
string
Organization ID
string
Project ID
string
Parent branch ID to fork from. Cannot be combined with —no-parent.
boolean
default:"false"
Create a root branch with no parent, instead of forking one
string
Branch name
string
Instance type for the branch
string
Number of read replicas for the branch
string
Region to create the branch in
string
PostgreSQL version for the branch
true | false
Scale to zero status for the branch
15 | 30 | 60 | 120 | 180
Inactivity period in minutes for the branch
boolean
default:"false"
Output in JSON format
string
The profile to use
Examples:

delete

Delete a branch The branch checked out in this folder cannot be deleted, and outside an interactive terminal the confirmation has to come from --yes.
Deleting a branch destroys its database and cannot be undone.
string
Organization ID
string
Project ID
string
Branch ID
boolean
default:"false"
Do not ask for confirmation, assume yes.
boolean
default:"false"
Output in JSON format
string
The profile to use
string
The branch to delete
Examples:

logs

Retrieve the PostgreSQL logs of a branch Reads the logs of every instance of the branch, the primary and any replicas, which is where slow queries, connection issues and replication problems show up. Requires the logs:read scope on the API key. Of the output formats, raw prints <timestamp> [<level> <instanceID> <process>] <message> per line, json a single array, ndjson one object per line for streaming into another process, and csv the columns timestamp,level,instanceID,process,message. Follow mode polls every 2 seconds with a 5 second overlap and de-duplicates entries. Logs can contain connection strings and other credentials, see https://xata.io/docs/platform/logs for what is redacted.
string
Organization ID
string
Project ID
string
Branch ID
debug | info | warning | error
Filter by log level. Can be repeated.
string
Filter by branch instance ID. Can be repeated.
string
Filter by process name. Can be repeated.
Case-insensitive substring search in the log message body. For regex filtering, pipe raw output to rg/grep, e.g. xata branch logs —output raw | rg ‘timeout|deadlock’
string
Start time as YYYY-MM-DDTHH:mm:ss.sssZ or relative duration, e.g. 15m, 1h, 7d. Defaults to 1h ago.
string
End time as YYYY-MM-DDTHH:mm:ss.sssZ or relative duration. Defaults to now.
string
default:"100"
Maximum number of logs to fetch, up to 1000
boolean
default:"false"
Poll for new logs continuously. Cannot be combined with —output json
raw | json | ndjson | csv
default:"raw"
Output format
boolean
default:"false"
Output in JSON format. Alias for —output json.
string
The profile to use
string
The branch to retrieve logs for
Examples:

url

Print URL (connection string) for a branch Reads the connection details from the credentials endpoint, so an API key needs the credentials:read scope, see https://xata.io/docs/cli#required-scopes.
string
Organization ID
string
Project ID
string
Branch ID
string
Database name
primary | primary-or-replica | replica | pooler
default:"primary"
Connection type: primary (direct access to the primary), primary-or-replica (routed access to primary or replicas), replica (read-only access to replicas only, requires at least one replica), pooler (pooled access to the primary, recommended for serverless and high-concurrency workloads)
string
The profile to use
string
The branch to get URL for
Examples:
Aliases: xata branch connection-string

checkout

Check out a branch in this folder Writes the branch to .xata/ in this folder, so later commands run against it without being told which branch to use.
string
Organization ID
string
Project ID
string
Branch ID
string
Database name
boolean
default:"false"
Output in JSON format
string
The profile to use
string
The branch to switch to
Examples:

tree

List all branches as a tree
string
Organization ID
string
Project ID
string
Branch ID
boolean
default:"false"
Show branch IDs in the tree
string
The profile to use
Aliases: xata branch topology

get

Get a field from a branch description Run it without a field to list the fields the description holds.
string
Organization ID
string
Project ID
string
Branch ID
string
The profile to use
string
Branch name and/or field to get
Examples:

metrics

Show CPU, memory and disk usage for a branch Reports the metrics of every instance of the branch, the primary and any replicas, as a snapshot or continuously with —watch.
string
Organization ID
string
Project ID
string
Branch ID
string
Time range ending now, such as 1h, 24h, or 7d
string
Start time as an ISO timestamp
string
End time as an ISO timestamp
string
default:"default"
Metrics to query: default, all, or a comma-separated list
string
default:"all"
Instances to query: all, primary, replicas, or comma-separated instance IDs
string
default:"avg,max,min"
Aggregations to query: comma-separated avg,max,min
avg | max | min
default:"avg"
Aggregation to render in table or TUI output
string
default:"10s"
Refresh interval for watch mode, such as 10s, 1m, or 500ms
table | json | ndjson | tui
default:"table"
Output format
boolean
default:"false"
Refresh metrics continuously
boolean
default:"false"
Output in JSON format
string
The profile to use
string
The branch to show metrics for
Examples:

set

Set a field value for a branch The postgres-version field upgrades PostgreSQL, and only accepts compatible upgrades within the same major version and offering type, see https://xata.io/docs/platform/branch#upgrading-postgresql-versions.
string
Organization ID
string
Project ID
string
Branch ID
boolean
default:"false"
Output in JSON format
string
The profile to use
string
The field to set: name, replicas, instance-type, storage, hibernate, scale-to-zero, inactivity-period or postgres-version
string
The value to set. Prompted for when omitted in an interactive terminal
Examples:

rotate-password

Rotate the database password for a branch Reads the current username from the credentials endpoint, so an API key needs the credentials:read scope, see https://xata.io/docs/cli#required-scopes.
string
Organization ID
string
Project ID
string
Branch ID
boolean
default:"false"
Do not ask for confirmation, assume yes.
boolean
default:"false"
Output in JSON format
string
The profile to use
string
The branch to rotate the password for

wait-ready

Wait for a branch to be ready Blocks until the branch is healthy, which is what a script needs after creating one or after a change that restarts it. A hibernated branch stays hibernated unless --wake is passed.
string
Organization ID
string
Project ID
string
Branch ID
boolean
default:"false"
Output in JSON format
boolean
Wake up the branch if it is hibernated
string
The profile to use
string
The branch to wait for
Examples:

query-insights

Inspect query statistics and active queries for a branch Which statements are slow, which are expensive, and what is running right now. Historical statistics come from pg_stat_statements, and the queries running at this moment from pg_stat_activity. Running xata branch qi without a subcommand is the same as xata branch qi list. Except for active, which reads pg_stat_activity, these commands need pg_stat_statements loaded: run xata branch query-insights enable <branch> and then wait for the restart with xata branch wait-ready <branch> --wake. Unlike logs and metrics, which go through the API, these commands open a direct PostgreSQL connection: they cannot run against a branch that is hibernated or still provisioning, and an API key needs the credentials:read scope. The console reads the same pg_stat_statements data, see https://xata.io/docs/platform/query-insights. Aliases: xata branch qi

query-insights list

List historical query statistics for a branch, by total execution time In table output a leading ! marks a row worth a look, a slow mean, spikes far above it, a low cache hit rate, heavy temporary file use or a very large row count, and the command prints the show command for each flagged query. Below the table it prints how many queries are being shown and, when more remain, the list command that fetches the next page. Both json and ndjson emit { "total", "limit", "offset", "queries" }, with the statements under queries.
string
Organization ID
string
Project ID
string
Branch ID
string
Search query text, database, or role
string
Comma-separated query types: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, OTHER
string
Comma-separated performance categories: fast, moderate, slow
string
Comma-separated database names to include
string
Comma-separated role names to include
total-time | mean-time | min-time | max-time | stddev-time | calls | rows | shared-hit | shared-read | shared-dirtied | shared-written | local-hit | local-read | local-dirtied | local-written | temp-read | temp-written | database | user
default:"total-time"
Sort by a query insight metric or dimension
asc | desc
default:"desc"
Sort direction
string
Maximum number of rows to return. Defaults to 50 for human output and 1000 for —json.
string
default:"0"
Number of rows to skip
boolean
default:"false"
Show all pg_stat_statements metrics in human output
table | json | ndjson | tui
default:"table"
Output format
boolean
default:"false"
Output in JSON format. Alias for —output json.
string
The profile to use
string
The branch to inspect
Examples:
Aliases: xata branch query-insights ls

query-insights show

Show full query statistics for a query ID A query ID is not unique on its own, the same normalized statement is recorded once per database and role that ran it. When the ID matches more than one row the command exits non-zero, re-run it with --db and --role. Human output ends with the potential issues found for the query.
string
Organization ID
string
Project ID
string
Branch ID
string
Database name to disambiguate the query ID
string
Role name to disambiguate the query ID
boolean
default:"false"
Output in JSON format
string
The profile to use
string
required
Query ID from pg_stat_statements
string
The branch to inspect
Examples:
Aliases: xata branch query-insights get

query-insights active

List currently running queries for a branch Reads pg_stat_activity, so it works without pg_stat_statements being loaded. The columns are PID, Age, State, Wait, DB, User, Client and Query.
string
Organization ID
string
Project ID
string
Branch ID
string
Refresh interval in seconds. Cannot be combined with —json
boolean
default:"false"
Output in JSON format
string
The profile to use
string
The branch to inspect
Examples:

query-insights enable

Enable pg_stat_statements for query insights on a branch Adds pg_stat_statements to the preloaded libraries, which restarts the branch, and creates the extension. Run it, wait for the branch with xata branch wait-ready <branch> --wake, then run it again to create the extension. Operations that rebuild a branch, such as a migration into it, can drop the extension, so run this again if query insights stop returning rows. The same can be done from the console, by adding it to the preloaded libraries in the branch settings, see https://xata.io/docs/platform/extensions.
string
Organization ID
string
Project ID
string
Branch ID
boolean
default:"false"
Output in JSON format
string
The profile to use
string
The branch to enable query insights for

query-insights reset

Reset accumulated query statistics for a branch Calls pg_stat_statements_reset(), which requires elevated privileges.
Resetting is branch-wide and cannot be undone, all historical counters are discarded and rebuild as new queries run.
string
Organization ID
string
Project ID
string
Branch ID
boolean
default:"false"
Do not ask for confirmation, assume yes.
boolean
default:"false"
Output in JSON format
string
The profile to use
string
The branch to reset query statistics for