All skills
planetscale avatar

/vitess

@51f2d4b official

Vitess best practices, query optimization, and connection troubleshooting for PlanetScale Vitess databases. Load when working with Vitess databases, sharding, VSchema configuration, keyspace management, or MySQL scaling issues.

Use this Skill: https://skilld.dev/gh/planetscale/database-skills/vitess

This session only. Nothing lands on disk.

referencesvreplication.md

≈995 tokens on demand. Your agent reads this file only when SKILL.md points to it.

VReplication

VReplication is Vitess's core data movement engine. It streams binlog events from source to target in near-real-time, powering MoveTables, Reshard, Materialize, and Online DDL.

Reference: https://vitess.io/docs/23.0/reference/vreplication/

MoveTables

Moves tables between keyspaces without downtime. Use for vertical sharding, migrating into Vitess, or changing sharding keys.

Lifecycle: create → [copy] → [replicate] → switchtraffic → complete

# Create workflow
vtctldclient MoveTables --workflow mv1 --target-keyspace customer \
  create --source-keyspace commerce --tables "customer,orders"

# Monitor, verify, switch, complete
vtctldclient MoveTables --workflow mv1 --target-keyspace customer status
vtctldclient VDiff --workflow mv1 --target-keyspace customer create
vtctldclient MoveTables --workflow mv1 --target-keyspace customer switchtraffic
vtctldclient MoveTables --workflow mv1 --target-keyspace customer complete

Key flags: --on-ddl (IGNORE|STOP|EXEC|EXEC_IGNORE), --defer-secondary-keys (faster copy for large tables), --enable-reverse-replication (true by default, enables rollback), --sharded-auto-increment-handling=replace (for unsharded→sharded moves).

Rollback: reversetraffic (after switch) or cancel (before switch).

Reshard

Splits or merges shards horizontally. Same lifecycle as MoveTables.

# Split 2 shards into 4
vtctldclient Reshard --workflow rs1 --target-keyspace customer \
  create --source-shards "-80,80-" --target-shards "-40,40-80,80-c0,c0-"

vtctldclient VDiff --workflow rs1 --target-keyspace customer create
vtctldclient Reshard --workflow rs1 --target-keyspace customer switchtraffic
vtctldclient Reshard --workflow rs1 --target-keyspace customer complete

Shard naming: hex key ranges. -80 = first half, 80- = second half, - = entire range (unsharded).

Materialize

Creates continuously-updated materialized views, optionally across keyspaces with transformations.

vtctldclient Materialize --workflow mat1 --target-keyspace reporting \
  create --source-keyspace commerce --table-settings '[{
    "target_table": "sales_summary",
    "source_expression": "SELECT region, SUM(total) as total_sales FROM orders GROUP BY region",
    "create_ddl": "CREATE TABLE sales_summary (region VARCHAR(64), total_sales DECIMAL(10,2), PRIMARY KEY (region))"
  }]'

VDiff

Verifies data consistency between source and target. Reports matching, missing, extra, and mismatched rows. Always run VDiff before switchtraffic in production.

vtctldclient VDiff --workflow mv1 --target-keyspace customer create
vtctldclient VDiff --workflow mv1 --target-keyspace customer show last

VStream

VStream is the underlying streaming API that powers all VReplication workflows above. It also provides change data capture (CDC) via VTGate gRPC API, streaming binlog events across all shards in a keyspace. Supports GTID-based positioning, table filtering, and resumable streams. Each event contains table name, operation (INSERT/UPDATE/DELETE), and row data.

Traffic switching

Both MoveTables and Reshard support granular traffic switching:

  1. Switch read traffic first (replica/rdonly) to verify correctness
  2. Switch write traffic (brief write pause during cutover)
  3. Roll back with reversetraffic if issues arise

VTGate buffers queries during switches to minimize application impact.

Key flags for switchtraffic: --timeout (max wait for replication catch-up, default 30s), --max-replication-lag-allowed, --dry-run.

Best practices

Always run VDiff before switching traffic. Use --defer-secondary-keys for large tables. Switch reads first, then writes. Keep reverse replication enabled for rollback. Monitor VReplication lag. Use --on-ddl=STOP in production.

Source: SKILL.md on GitHub

1 warning17d5 checks · Risk SAFE
  • Gen Agent Trust Hub17d

    The skill provides comprehensive documentation and best practices for Vitess and PlanetScale databases. It consists entirely of informational markdown files without executable scripts, dependencies, or network operations outside of referencing official vendor resources.

  • Socket17d

    No alerts

  • Snyk17d

    Risk: LOW · No issues

  • Runlayer6mo

    5/6 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 51f2d4b. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Activeupdated 7 months ago
Other metadata
metadata
{
  "author": "planetscale",
  "version": "1.0.0",
  "organization": "PlanetScale",
  "date": "February 2026"
}
  • Database
  • vitess
  • planetscale
  • mysql
  • sharding
  • vschema
  • connection-pooling
  • schema-migrations

README badge

README badge for planetscale/database-skills/vitess

Guides query routing, sharding strategy, schema migration, and MySQL compatibility for Vitess databases on PlanetScale. Covers VSchema configuration, keyspace management, cross-shard query performance, and Online DDL workflows.

Generated from the current SKILL.md.

Does Vitess support stored procedures and triggers?
No. Stored procedures, triggers, and events are not supported through VTGate. Application logic must handle these operations.
What should I use for generating IDs on sharded tables?
Use Vitess Sequences (a global counter in an unsharded keyspace) or app-generated IDs like UUIDs or snowflakes to avoid collisions across shards.
Are cross-shard joins supported?
Yes, but they are expensive scatter-gather operations. Filter by the vindex column to force single-shard routing and avoid cross-shard joins when possible.
How do I apply schema changes in production on PlanetScale?
Use PlanetScale deploy requests, which implement non-blocking Online DDL migrations across all shards without disrupting workloads.
Does Vitess support foreign keys?
Foreign keys have limited support in Vitess. Prefer application-level referential integrity checks on sharded keyspaces.

Generated from the current SKILL.md. These answers refresh after source changes.