Databases 5 min read

Using Hints in DBLE to Control Routing and Execute Custom SQL

This article explains how DBLE's hint mechanism can be used to specify database routing, classify different hint types, and demonstrate practical operations such as invoking stored procedures and executing custom SQL statements on selected nodes.

Aikesheng Open Source Community
Aikesheng Open Source Community
Aikesheng Open Source Community
Using Hints in DBLE to Control Routing and Execute Custom SQL

In previous sessions we introduced the Global table and ER table; in addition, DBLE provides a hint feature to specify routing.

What is a Hint A hint is an effective comment that allows a business application to designate a specific shard, enabling the middleware to dispatch SQL in the designated way. The hint contains routing results, for example ID=1, and after the routing calculation the actual SQL executed may be different, but the hint conveys the routing intention.

For example, the statement insert xx select * from xxx is not currently supported by DBLE, but the same effect can be achieved through a hint, which specifies the routing result while the actual executed SQL may differ.

Hint Classification

DBLE hints are divided into several types: one that calculates routing via SQL, one that directly specifies the target node, and a third type that forces a SELECT to read from the primary node in a read‑write split scenario.

Operation Demonstration We demonstrate using a hint with a stored procedure. Using the DBLE MySQL client, we look at table tb_mod which contains five rows. Suppose we want to delete data on a specific node; the process is simple: we issue a delete * from tb_mod statement preceded by a hint that points to tb_mod=1 . After executing the stored‑procedure call, the rows with IDs 1 and 5 are removed. This shows how hints can direct execution to a particular node for operations that DBLE does not natively support, such as insert select * from table and similar statements.

That concludes the introduction for today.

For easier reading, some colloquial wording has been optimized without affecting learning; the text and video aim to stay consistent.

DBLE and related project code repositories: https://github.com/actiontech/dble https://github.com/actiontech/dble-docs-cn https://github.com/actiontech/dble-test-suite

Course inquiries: WeChat public account: ActiontechOSS Official technical group: 669663113

Click “Read Original” to get the latest lessons of the "DBLE Quick Start" series!

SQLMiddlewareHintStored ProcedureDBLEdatabase routing
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

login 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.