Note
This stored procedure is supported starting from V4.6.2.1.
The TRIGGER_ASYNC_TASK stored procedure can be used to manually trigger background maintenance tasks for specified types of vector indexes on demand, with operations refined down to specific tablets. It is suitable for scenarios where precise control over index maintenance is required. This procedure supports multiple task types. After a task is initiated, you can use system views such as DBA_OB_VECTOR_INDEX_TASKS to monitor the task execution progress and results in real time.
Syntax
PROCEDURE TRIGGER_ASYNC_TASK(
IN DATABASE_NAME VARCHAR(65535),
IN TASK_TYPE VARCHAR(65535),
IN TABLE_NAME VARCHAR(65535),
IN INDEX_NAME VARCHAR(65535),
IN TABLET_ID BIGINT
);
Parameters
Parameter |
Type |
Description |
|---|---|---|
| database_name | VARCHAR | The name of the database. |
| task_type | VARCHAR | Task type. Valid values are listed in the following table. |
| table_name | VARCHAR | The name of the target table. |
| index_name | VARCHAR | Vector index name. |
| tablet_id | BIGINT | Target tablet ID, which must belong to the specified vector index. For the query method, see below. |
The following table describes the values of task_type.
Value |
Note |
|---|---|
| INCREMENTAL_INDEX_FREEZE | Trigger incremental segment freezing (minor compaction). |
| INCREMENTAL_INDEX_MERGE | Trigger incremental segment major compaction. |
| FOLLOWER_IN_MEMORY_INDEX_REFRESH | Triggers memory loading for the follower. |
Query the tablet_id method:
- You can query the
TABLET_IDcorresponding to a vector index by database name and index name through the DBA_OB_TABLE_LOCATIONS view:SELECT DISTINCT TABLET_ID, TABLE_NAME, INDEX_NAME, PARTITION_NAME, SUBPARTITION_NAME FROM oceanbase.DBA_OB_TABLE_LOCATIONS WHERE DATABASE_NAME = 'test' AND INDEX_NAME = 'my_vector_idx'; - For vector indexes already loaded into memory, you can also query them using the
DATA_TABLET_IDfield in the index performance views V$OB_HNSW_INDEX_INFO, V$OB_SINDI_INDEX_INFO, and V$OB_IVF_INDEX_INFO.
Global considerations
- Before executing this stored procedure, ensure you have the
ALTERprivilege on the target table. - Manually triggered tasks are scheduled and executed with the highest priority to ensure timely response.
- If an unsupported task type is provided, the system will return error code
1235and abort execution.
Examples
Manually trigger the freeze of incremental segments for a specified tablet:
CALL DBMS_VECTOR.TRIGGER_ASYNC_TASK('test', 'INCREMENTAL_INDEX_FREEZE', 'my_table', 'my_vector_idx', 200001);
Manually trigger incremental segment compaction for a specified tablet:
CALL DBMS_VECTOR.TRIGGER_ASYNC_TASK('test', 'INCREMENTAL_INDEX_MERGE', 'my_table', 'my_vector_idx', 200001);
Manually trigger memory loading for the follower of a specified tablet:
CALL DBMS_VECTOR.TRIGGER_ASYNC_TASK('test', 'FOLLOWER_IN_MEMORY_INDEX_REFRESH', 'my_table', 'my_vector_idx', 200001);