Skip to main content

Getting Started

Make sure to first set up your PlanetScale developer environment. Once you’ve installed the pscale CLI, you can interact with PlanetScale and manage your databases straight from the command line.

The materialize command

Run Vitess Materialize workflows on a Vitess database branch. Materialize keeps target tables in sync in near-realtime. Targets can be copies, aggregations, or views of source tables. Prefer move-tables when you only need to copy tables between keyspaces. Prefer Materialize when the target needs a different schema or a SELECT that filters or aggregates rows. Usage:
pscale branch vtctld materialize also works.
You must be an Organization Administrator or a Database Administrator of the database to create and change Materialize workflows. Service tokens need read_workflow to show a workflow, write_workflow to create, start, or stop one, and delete_workflow to cancel one.

Available sub-commands

* Flag is required

Sub-command flag descriptions

Available flags

Global flags

--table-settings

--table-settings is a JSON array. Each object needs:
  • target_table — table name in the target keyspace
  • source_expression — a SELECT against a single source table
Optional create_ddl:
  • "copy" — copy the source table schema as-is
  • a CREATE TABLE statement — create a custom target schema
Vitess limits which SELECTs Materialize accepts (no JOINs, no OR/LIKE, expressions need aliases, and more). See the Vitess Materialize docs. Example:

Lifecycle

  1. Create the workflow with --table-settings.
  2. Show the workflow until streams are replicating.
  3. Read from the target tables once they are in sync.
  4. Stop / start to pause and resume, or cancel to tear the workflow down.

Examples

Dashboard and API

The Workflows page lists Materialize workflows next to MoveTables workflows and shows stream state, lag, and each target table’s query. It is read-only — create, start, stop, and cancel stay in the CLI or API. See Workflows. Matching API paths under /v1/organizations/:org/databases/:db/branches/:branch/materialize/workflows.

Need help?

Get help from the PlanetScale Support team, or join our Discord community to see how others are using PlanetScale.