Getting Started
Make sure to first set up your PlanetScale developer environment. Once you’ve installed thepscale CLI, you can interact with PlanetScale and manage your databases straight from the command line.
The insights command
Surface PlanetScale’s server-side analysis of a database: aggregated query statistics, failing query patterns, resource anomalies, and schema recommendations, all computed from production traffic.
For live, connection-level diagnostics (table sizes, locks, running queries), use pscale inspect instead.
Query insights require Query Insights to be enabled for the database. See Postgres or Vitess. Postgres and Vitess branches are supported.
Usage:
--org is required.
Available sub-commands
Available flags
Examples
The queries sub-command
List the top queries for a branch, ranked by cumulative execution time (default).
Usage:
Examples:
The queries samples sub-command
List recent executions for a specific query fingerprint. Use the fingerprint from pscale insights queries. --keyspace is required.
Usage:
Example:
queries show takes an individual execution/sample id from queries samples. queries samples and queries summary take a query fingerprint. These identifiers are not interchangeable.
The queries show sub-command
Show one query execution using an ID returned by pscale insights queries samples.
The queries summary sub-command
Show aggregate statistics for a fingerprint from pscale insights queries. --keyspace is required (use the keyspace column from the queries list).
Available flags:
--period cannot be combined with --from and --to. Both range flags must be set together.
The queries traffic-budgets sub-command
List traffic budgets that affect a query fingerprint. Pass --keyspace from the queries list. The command is paginated; pass --page for the next page instead of walking every page automatically.
Available flags:
The errors sub-command
List failing query patterns with error messages.
Usage:
Example:
errors show
List the individual executions that failed with an error fingerprint, including the users, keyspaces, and
statements involved. Use the fingerprint column from insights errors (error_fingerprint in JSON), not
the truncated id.
Available flags:
The anomalies sub-command
List detected resource anomalies for a branch.
Usage:
anomalies show
Show one anomaly from insights anomalies, along with the queries whose activity correlates with it.
The tags sub-command
List query tag keys from sqlcommenter / system tags on a branch.
Usage:
Example:
tags show
Show a query tag key and its values.
tags summaries
List query statistics grouped by one or more tag keys. --tags is required and repeatable.
The recommendations sub-command
List schema recommendations for a database: unused tables and indexes, duplicate indexes, bloated tables and indexes, missing indexes derived from production query patterns, and sequence overflow risks. Each recommendation includes ready-to-apply DDL in JSON output.
This sub-command takes a database name only (not a branch).
Usage:
recommendations show
Show a single schema recommendation, including the full ready-to-apply DDL. <number> is the recommendation sequence number from pscale insights recommendations, the same value used by recommendations dismiss.
recommendations dismiss
Dismiss a schema recommendation. Use the recommendation number from pscale insights recommendations. Interactive confirmation is required unless --force is passed.

