OceanBase Migration Service (OMS) supports adding user-specified hints to the query/slicing SQL used by components to access databases in full migration, full verification, and row count verification scenarios. This helps optimize execution plans and improve query efficiency.
Background information
On-site database conditions can be complex, and the default query methods may result in incorrect execution plans due to the database's own reasons, affecting migration or verification performance. By configuring SQL hints, you can manually intervene in the query execution plan to make it more efficient.
Supported scenarios
SQL hints are supported for the following components and scenarios:
- Full-Import: Inject hints into source-side query and slicing SQL.
- Full-Verification: Inject hints into source and target query/slicing SQL.
- Row-Verification: Inject hints into source and target query SQL.
Configuration method
OMS supports configuring hints individually for a single table, or uniformly for multiple tables or all tables. SQL hints are configured using the component parameters componentFullHint and componentHint. You can choose any of the following entry points to configure them.
Configure during task creation
- Data migration tasks: In the Migration Options step, click Parameter Configuration in the lower-right corner, and configure hint parameters on the Full Migration tab.
- Data verification tasks: In the Validation Options step, click Parameter Configuration in the lower-right corner, and configure hint parameters on the Full Validation or Row Count Validation tab.
In the Template Parameter Configuration section, click Add Parameter, and set Parameter Name, Value Type (set to STRING), and Parameter Value in sequence. For the format of the parameter value, see below.
Configure via a component template
- In the left navigation bar, click OPS & Monitoring > Parameter Template. The Component Template tab opens by default.
- Select the component type Full-Import, Full-Verification, or Row-Verification, click Create Component Template, add hint parameters in the format described above, and save.
- When creating a data migration or data verification task, reference this component template via Select Parameter Template in the Parameter Configuration drawer.
Note
If the configured parameters conflict with those selected on the relevant page when creating the task, the page options will take precedence.
Global configuration
Configure hints uniformly for all tables:
componentFullHint=/*+ PARALLEL(4) */
Single table configuration
To configure a hint for a specific table, use the format database_name.table_name=hint. Separate multiple tables with semicolons (;):
componentHint=db1.t1=/*+ INDEX(t1 idx1) */;db2.t2=/*+ PARALLEL(8) */
Notice
componentFullHint and componentHint are entry points in task parameter configuration and component templates. When writing SQL hints directly in the source or target configuration of a component, you must use the mappings under querySliceHint, queryDataHint, and tableConf. The string representation of componentHint cannot be used directly as table-by-table configuration for a component.
Parameter entry points and configuration snippets
Full-Import
Full-Import reads the hints for slicing SQL and reading data SQL from the JDBC source configuration separately:
- Global:
querySliceHint (slicing SQL) and queryDataHint (reading data SQL) in the source configuration.
- Table-wise:
querySliceHint and queryDataHint in tableConf of the source configuration, with values being mappings keyed by database_name.table_name.
When configuring a data reading hint only for user-specified tables, the source configuration snippet is as follows:
{
"tableConf": {
"queryDataHint": {
"db1.t1": "/*+ PARALLEL(4) */"
}
}
}
When configuring a data reading hint for all tables, place the hint under queryDataHint in the same source configuration:
{
"queryDataHint": "/*+ PARALLEL(4) */"
}
Full-Verification
Full-Verification is distinguished between the source and target, and the databases at both ends may use different dialects. Do not apply the same hint to both ends simultaneously. When adding a hint for the target, configure the target parameters separately:
- Source:
querySliceHint (slicing SQL) and queryDataHint (reading data SQL) in the source configuration.
- Target:
querySliceHint (slicing SQL) and queryDataHint (reading data SQL) in the target configuration.
The configuration snippet that takes effect only for data reading at the source is as follows:
{
"task": {
"sourceMasterSection": {
"queryDataHint": "/*+ PARALLEL(4) */"
}
}
}
When configuration is needed for both ends, add task.sourceImageSection.queryDataHint to the same configuration and write the hint content according to the target dialect.
Row-Verification
Row-Verification is also distinguished between the source and target. Hints are only injected into the query SQL. The naming of the configuration entry point is consistent with Full-Verification.
Supported data sources and hint formats
The hint formats supported by different data sources are as follows:
Data Source
Hint format
Description
OceanBase Database (MySQL/Oracle compatible mode)
/*+ ... */
SupportedPARALLEL、INDEX、LEADING、USE_HASHetc.
Oracle Database
/*+ INDEX(t i) */
Classic hint system with the largest variety of hints
MySQL Database
/*+ MAX_EXECUTION_TIME(1000) */
Optimizer hints are supported in OceanBase Database V5.7.7 and later. In addition,FORCE INDEXIndex Prompt
TiDB Database
/*+ ... */
MySQL-compatible syntax
SQL Server
OPTION (MAXDOP 1) / WITH (NOLOCK)
Supports query hints, table hints, and connection hints
DM Database
/*+ ... */
OMS uses a hint system similar to that of Oracle. OMS directly inlines hints into the queries executed by components. This inline writing method does not require enabling the instance parameterENABLE_INJECT_HINT. This parameter is used to specify the database-side information through theSF_INJECT_HINTScenarios where hint binding rules apply.
DB2 LUW
/* <OPTGUIDELINES> ... */
Embedded Optimization Guide + Optimization Profile
Notice
The contents of a hint are directly concatenated into the SQL statement executed by the component. Ensure that the hint syntax is compatible with the target database. Incorrect hint syntax may cause the query to fail or be ignored by the database.
References