Vertical sharding
Vertical sharding moves whole tables to another database, while horizontal sharding splits the rows of one table. The course compares the two axes and shows that this Rails 8 application already splits its data into four database roles. It uses foreign keys to measure coupling and find seams. It explains which guarantees stop working across a seam and walks through the Rails setup for a new database. It closes by testing the one candidate table in this schema and a challenge that lists the queries a split would break.
What you'll learn
- ✓The difference between horizontal and vertical sharding
- ✓How Rails 8 gives queue, cache and cable tables their own database roles
- ✓Measuring table coupling with foreign keys to find seams
- ✓What stops working across a seam: joins, transactions and foreign key constraints
- ✓Adding a database in Rails with connects_to and its own migration path
- ✓Judging whether a movable table is worth moving
Splitting tables, not rows
Vertical sharding moves whole tables to another database. Horizontal sharding splits one table's rows, and vertical sharding splits the set of tables.
Read the full lesson free →Curriculum
7 lessonsSplitting tables, not rows
Compares horizontal and vertical sharding, what moving whole tables gives a workload, and the joins and transactions it costs.
You are already doing it
Shows how Rails 8 already splits this application into primary, queue, cache and cable roles, and why the cache moved.
Finding the seam
Uses foreign key counts per table to find seams, and adds a second test of whether moving is worthwhile.
What breaks at the seam
Explains how joins, transactions and foreign key constraints stop working once a table lives in another database.
Doing it in Rails
Covers database.yml, an abstract base class, migration paths, copying data and the connection cost of adding a database.
The candidate here
Tests the three movable tables and explains why partner_inquiries is separable but still should not be split.
Putting it together
Summarizes the course and sets a challenge: list the queries that a proposed split would break, with validation.