BUILD INDEX triggers a secondary index build after you submit an asynchronous index building task. It applies only to LindormTable versions later than 2.2.16 and equal to or earlier than 2.6.3.
Version compatibility
The behavior of BUILD INDEX differs across LindormTable versions:
| LindormTable version | Behavior |
|---|---|
| > 2.2.16 and ≤ 2.6.3 | After submitting an asynchronous index building task, run BUILD INDEX separately to trigger the build. |
| > 2.6.3 | BUILD INDEX is not required. Index creation is handled automatically after you initiate the async build request. |
Syntax
BUILD INDEX [ index_identifier ]
ON table_identifier| Parameter | Description |
|---|---|
index_identifier | Name of the index to build. Run SHOW INDEX to list all indexes on a table. |
table_identifier | Name of the table for which to build the index. |
Usage notes
Concurrency limits
LindormTable enforces the following limits on concurrent index building tasks:
A maximum of 2 index building tasks can run at the same time across all tables.
Only 1 index building task can run per table at a time.
This means two tasks can run simultaneously only if each targets a different table.
If you submit two or more tasks for the same table, only the first task succeeds. Additional tasks fail immediately. To run another task on that table, wait until the first task reaches INDEX_STATE = ACTIVE and INDEX_PROGRESS = 100%, then submit a new BUILD INDEX statement.
Similarly, if two tasks are already running on two different tables, any additional tasks fail until the two tasks are complete.
Index build status
Use SHOW INDEX to monitor index build progress. The following fields indicate the current state of a build:
| Field | Value | Meaning |
|---|---|---|
INDEX_STATE | BUILDING | The task failed to start due to a concurrency conflict. |
INDEX_STATE | ACTIVE | The index was built successfully and is ready for use. |
INDEX_PROGRESS | N/A | The task failed because the concurrency limit was exceeded. |
INDEX_PROGRESS | 100% | The build completed successfully. |
Example
Build a secondary index named idx1 on the table test:
BUILD INDEX idx1 ON test;Verify the result
Run the following statement to confirm the index was built successfully:
SHOW INDEX FROM test;The index is ready when INDEX_STATE is ACTIVE and INDEX_PROGRESS is 100%.