HINTs are supplementary SQL syntax that controls how a statement is executed. Lindorm wide table SQL supports HINTs for operations such as multi-version data management.
Prerequisites
The wide table engine must be version 2.3.1 or later. To view or upgrade the current version, see Wide table engine version guide and Upgrade a minor version.
Limits
-
A HINT must be used after the INSERT, UPSERT, DELETE, or SELECT keyword.
-
For wide table engine versions earlier than 2.5.2.1, HINTs are supported only for simple queries and are not supported for complex queries such as subqueries or group queries.
HINT syntax
hintExpression ::= /*+ hintItems */
hintItems ::= hintItem (',' hintItem )*
hintItem ::= identifier ('(' hintOption ( ',' hintOption)* ')')?
identifier ::= ( [A-Z] | '_' ) ( [A-Z] | [0-9] | '_' | '@' | ':')*
-
A HINT uses the format
/*+ hintItems */.hintItemsis a HINT statement for a specific operation. MultiplehintItemsare separated by commas (,). -
In a Lindorm wide table SQL statement, a HINT can be specified only after the INSERT, UPSERT, DELETE, or SELECT keyword. The following example is invalid:
UPSERT INTO /*+ _l_ts_(3000) */ t_test_ts(c1, c3) VALUES (1, 'c3');.
hintOption parameter descriptions
|
Parameter |
Data type |
Description |
|
_l_operation_timeout_ Note
For wide table engine versions earlier than 2.5.2.1, this parameter is named operationtimeout. |
INT |
The timeout period for a DML operation, in milliseconds. Default value: 120,000. The value must be greater than 0. Supported for Important
|
|
_l_force_index_ |
STRING |
Forces the use of a specified index. Supported only for Note
The _l_force_index_ parameter cannot be used with the _l_ignore_index_ parameter. |
|
_l_ignore_index_ |
Not applicable |
Ignores indexes and queries data directly from the data table, useful for comparing query performance with and without an index. No value is required. Supported only for Note
The _l_ignore_index_ parameter cannot be used with the _l_force_index_ parameter. |
|
_l_allow_filtering_ |
Not applicable |
By default, queries that filter on non-primary key columns return an error. This parameter allows full table scans on such columns. No value is required. Supported only for |
|
_l_versions_ |
INT |
Returns the latest N versions of data in the query results. The value must be greater than 0. Supported only for |
|
_l_ts_ |
BIGINT |
The timestamp for multi-version management, used when writing or querying non-primary key columns. The value must be greater than 0. Unit: milliseconds. Supported for |
|
_l_ts_min_ |
BIGINT |
The minimum timestamp for multi-version management, used to filter query results. The value must be greater than 0. Unit: milliseconds. Supported only for |
|
_l_ts_max_ |
BIGINT |
The maximum timestamp for multi-version management, used to filter query results. The value must be greater than 0. Unit: milliseconds. Supported only for |
|
_l_hot_only_ |
BOOLEAN |
Specifies whether to query only hot data. Supported only for Valid values:
|
Examples
-
Example 1: Set the timeout period for a DML operation to 30,000 ms in a row-count query.
SELECT /*+ _l_operation_timeout_(30000) */ COUNT(*) FROM t_test_ts;Result:
+----------+ | COUNT(*) | +----------+ | 1 | +----------+ -
Example 2: Set the timeout period for a DML operation to 30,000 ms when writing a row of data.
UPSERT /*+ _l_operation_timeout_(30000) */ INTO t_test_ts(c1, c2, c3) values(1,2,3); -
Example 3: Set the timeout period for a DML operation to 30,000 ms when deleting data that meets a specific condition.
DELETE /*+ _l_operation_timeout_(30000) */ FROM tb WHERE c1 = 1; -
Example 4: Use _l_force_index_ to force a query to use a specific index.
SELECT /*+ _l_force_index_('idx1') */ COUNT(*) FROM tb; // 'idx1' is the name of an existing index.Result:
+----------+ | COUNT(*) | +----------+ | 1 | +----------+ -
Example 5: Use _l_ignore_index_ to force a query to ignore indexes.
SELECT /*+ _l_ignore_index_ */ COUNT(*) FROM tb;Result:
+----------+ | COUNT(*) | +----------+ | 1 | +----------+ -
Example 6: Use _l_allow_filtering_ to allow filtering on a non-primary key column.
SELECT /*+ _l_allow_filtering_ */ COUNT(*) FROM tb WHERE c1 = 2;Result:
+----------+ | COUNT(*) | +----------+ | 1 | +----------+In this example,
c1is neither a primary key nor an index column. The HINT allows the query to run without an error. -
Example 7: Use _l_ts_ to specify a timestamp for a row to be written.
UPSERT /*+ _l_ts_(3000) */ INTO t_test_ts(c1, c3) VALUES (1, 'c3'); -
Example 8: Use _l_versions_ to retrieve the latest version of the data.
SELECT /*+ _l_versions_(1) */ c1, c3, c3_l_ts FROM t_test_ts;Result:
+----+----+---------+ | c1 | c3 | c3_l_ts | +----+----+---------+ | 1 | c3 | 3000 | +----+----+---------+
Scenarios
HINTs apply to the following scenarios: