Understanding Global Tables in DBLE: Configuration and Join Operations
This article explains what Global tables are in DBLE, how to configure them in schema.xml, and demonstrates their behavior during various JOIN operations across sharded databases, highlighting benefits and performance considerations for low‑change, low‑concurrency dictionary data.
In the previous episode we introduced various table splitting rules; now we discuss Global tables.
What is a Global table? It is a table with a small amount of dictionary data (e.g., supermarket product SKUs) that experiences few inserts, updates, or deletes and has low concurrent access, making it ideal for a Global table that is replicated on every shard.
A Global table has identical copies on multiple shards. For example, a sales table is split by date, while a product table can be copied unchanged to each database because it rarely changes and has little concurrency.
This design simplifies JOINs: the query can be routed based solely on the sales table distribution without worrying about the product table’s placement. The article then shows how DBLE configures Global tables.
Global Table Configuration In schema.xml two Global tables ( tb_global1 and tb_global2 ) are predefined, each with a type and datanode attribute. tb_global2 points to four nodes (dn1‑dn4), creating four identical replicas that must be kept consistent across those nodes.
When other sharded tables share the same four shards (or a subset), cross‑database INNER JOIN can be performed by the middleware, which collects data from all nodes and merges the results.
Global Table JOIN Operations
The example shows a sharded table tb_mod (modulo 4) and a Global table with two rows replicated on each node. An insert of a new row (id = 1024) is propagated to all four replicas, demonstrating DBLE’s two‑phase commit distributed transaction that keeps the data consistent.
When performing an INNER JOIN between tb_mod and the Global table, the middleware gathers all data and returns the correct result set (six rows). The same approach works for LEFT JOIN , but RIGHT JOIN is problematic because the Global table would need to supply rows that do not exist in the sharded table, leading to data loss on individual shards.
Therefore, while INNER JOIN with a Global table can be optimized, LEFT JOIN still triggers a cross‑database query, and RIGHT JOIN is generally unsupported. Users should carefully review SQL that involves Global tables to avoid performance issues.
For further study, the DBLE source code and documentation are available at:
https://github.com/actiontech/dble
https://github.com/actiontech/dble-docs-cn
https://github.com/actiontech/dble-test-suite
Course inquiries can be directed to the "ActiontechOSS" WeChat public account or the official technical discussion group (ID 669663113).
Aikesheng Open Source Community
The Aikesheng Open Source Community provides stable, enterprise‑grade MySQL open‑source tools and services, releases a premium open‑source component each year (1024), and continuously operates and maintains them.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.