Colocated tables Beta
In workloads that do very little IOPS and have a small data set, the bottleneck shifts from CPU/disk/network to the number of tablets one can host per node. There are practical limitations to the number of tablets that YugabyteDB can handle per node, even though this number could be very high, depending on the workload pattern. Since each table by default requires at least one tablet without colocation, a database with 5000 relations (tables, indexes, etc.) will have at least 5000 tablets, which increases the CPU/disk/network overhead. If most of these relations are small in size, then it’s beneficial to use colocated tables.
Colocating various SQL tables puts all of their data into a single tablet, called the colocation tablet.Note that all the data in the colocation tablet is still replicated across 3 nodes (or whatever the replication factor is).
In this section, we’ll explore creating and using colocated tables. If you haven’t installed YugabyteDB yet, do so first by following the Quick start guide.
You can create a universe by following .
2. Create a colocated database
Create database with colocated = true
option.
This will create a database whose tables will be stored on a single tablet.
Connect to northwind
database and create tables using standard command.The tables will be colocated on a single tablet since the database was created with colocated = true
option.
If you go to tables view in , you’ll see that all tables have the same tablet.
4. Opt out table from colocation
YugabyteDB has the flexibility to opt a table out of colocation. In this case, the table will use its own set of tabletsinstead of using the same tablet as the colocated database. This is useful for scaling out tables that we know are likelyto be large. You can do this by using option while creating table.
If you go to tables view in , you’ll see that orders
table has its own set of tablets.
What’s next?
For more information, see the architecture for .