Company
Date Published
Author
Jiten Vaidya
Word count
1992
Language
English
Hacker News points
None

Summary

PlanetScaleDB is a fully managed database-as-a-service on top of open source Vitess that enables horizontal scaling of MySQL far beyond what you can do with a single instance. Sharding in Vitess allows your application to treat a sharded database as though it is a humongous monolithic database without having to worry about the complexities of sharding. A VSchema defines how the data is organized in shards across multiple databases, and it consists of three elements: "sharded" indicating whether the database is sharded or not, "vindexes" defining all vindex types used in the VSchema, and "tables" one entry for each table with information about primary vindexes applied to columns. A Vindex maps a row to a shard by applying a specific sharding function to the value of a column in that row. Vitess sequences allow you to define ids which are monotonically increasing and unique across shards for a given table, solving the problem of duplicate values in an autoincrementing column. The Goodest Doggo dog rating application demonstrates how to organize data using two keyspaces: one unsharded keyspace holding tables for sequences and lookup Vindexes, and a sharded keyspace holding the actual data with Vitess sequences defining autoincrementing columns.