Databases 9 min read

DBLE Date-Based Sharding Algorithm: Band and Ring Modes, Configuration, Development and Operations Guidelines

This article explains DBLE’s date‑based sharding algorithm, describing its band and ring modes, the required rule.xml configuration parameters, development and operational considerations, and a comparison with MyCat’s similar sharding approach for large-scale deployments.

Aikesheng Open Source Community
Aikesheng Open Source Community
Aikesheng Open Source Community
DBLE Date-Based Sharding Algorithm: Band and Ring Modes, Configuration, Development and Operations Guidelines

Author : Zhong Yue, senior DBLE user and experienced architect who frequently works with MySQL and large‑scale projects.

DBLE treats each 24‑hour period as a time slice. In band mode , only a start date is defined; slices increase indefinitely from that date. In ring mode , both start and end dates are defined, and the total number of slices is fixed, with routing performed modulo the slice count.

When DBLE starts, it reads the following parameters from rule.xml:

1. <propertyname="sBeginDate"> – the start time. 2. <propertyname="sPartionDay"> – how many days each MySQL partition holds. 3. <propertyname="dateFormat"> – the date format for the partition index. 4. <propertyname="sEndDate"> (optional) – end time for ring mode. 5. <propertyname="defaultNode"> – fallback node for out‑of‑range indexes.

During runtime, when a query accesses a table using this algorithm, the WHERE clause’s partition index (a string) is extracted and converted to a Java date type. The difference between this index and the start time is divided by the number of days per partition to determine the target partition.

In ring mode, if the index is earlier than sBeginDate, it is routed to defaultNode; otherwise, the index is modulo‑ed by the fixed partition count.

Comparison with MyCat : Both DBLE and MyCat use a date‑based partitioning algorithm, and their modulo‑range behavior is essentially identical.

Development notes :

The partition index must be a string that java.text.SimpleDateFormat can parse according to the user‑specified dateFormat.

Both band and ring modes are supported.

Band mode creates a new slice every sPartionDay days starting from sBeginDate; the number of slices can grow indefinitely, but data before sBeginDate without a defaultNode will fail to route.

Ring mode fixes the number of slices based on the interval between sBeginDate and sEndDate; data before sBeginDate without a defaultNode also fails.

The index format is fully user‑defined via dateFormat.

Because slices are based on fixed 24‑hour periods, they do not align with calendar months or years and can be affected by leap‑second adjustments.

Operations notes :

In band mode, new slices appear automatically as data after sBeginDate arrives, requiring no rebalancing.

Band mode does not auto‑create physical partitions; operators must add them manually, otherwise routing to a non‑existent slice fails.

In ring mode, overlapping [sBeginDate, sEndDate] intervals may require partial data migration; non‑overlapping intervals need data rebalancing.

Configuration notes :

In rule.xml you can configure the following properties: <propertyname="sBeginDate">, <propertyname="sPartionDay">, <propertyname="dateFormat">, <propertyname="sEndDate">, and <propertyname="defaultNode">.

The dateFormat must follow java.text.SimpleDateFormat conventions and is used to parse sBeginDate and sEndDate. The sBeginDate and sEndDate values must match this format; providing sEndDate switches DBLE to ring mode, otherwise band mode is used. sPartionDay is a non‑negative integer indicating how many 24‑hour slices belong to a single partition. defaultNode is optional and defines the fallback partition for out‑of‑range indexes.

For further reading, see the DBLE sharding series:

Part 4: numberrange sharding

Part 3: enum sharding

Part 2: stringhash sharding

Part 1: hash sharding

Recent community events include the DBLE user meetup in Shanghai on June 15, 2019, featuring talks from the R&D, testing, product, and community teams.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

mysqlDBLEdate-partition
Aikesheng Open Source Community
Written by

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.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.