Troubleshoot and optimize vector search performance
This topic describes how to troubleshoot and optimize three types of performance issues: stalled vector search jobs, slow vector index builds, and slow vector index searches.
Vector search job stalls
-
Typical symptom: A vector search job makes no progress for an extended period. The stage that contains
AnnIndexScanin LogView cannot start enough Workers and continues to wait for resources. -
Resource and performance changes after adjustment: After
bucket_num_per_index_fileis changed from the default value1to4, the numbers of index files and search Workers and the corresponding resource requests are reduced to approximately1/4of their original values, a reduction of approximately 75%. This also reduces search parallelism. If sufficient resources were originally available, the search stage typically becomes slower. If the original job remained stalled because of insufficient resources, reducing parallelism allows it to start normally. Therefore, the end-to-end duration may not increase.
Symptom
In LogView, many instances are planned for the vector search stage, but no instance is running, as shown in the following figure:

LogView example: A large number of instances are planned for the vector search stage, but the actual number of running instances is 0, and the job progress remains at 0%. As shown in the following figure, the progress of the AnnIndexScan operator in LogView is 0%:

Operator details: The progress of AnnIndexScan is 0%, and the downstream stage cannot proceed.
Cause
This issue usually occurs because a large number of index files require the search stage to start more AnnIndexScan Workers than the current Quota can support. As a result, the job waits for an extended period.
When creating an index, increase bucket_num_per_index_file so that one index file contains multiple buckets. This reduces the number of index files and the number of Workers required in the search stage.
Before proceeding: Deleting an index temporarily affects search jobs that depend on the index. Perform the operation during a maintenance window and first record the algorithm, distance type, and build parameters of the original index. Keep all parameters except bucket_num_per_index_file consistent with those of the original index.
Procedure
The following example uses doc_table, embedding, and doc_vector_index. Before execution, replace them with the actual table name, vector column name, and index name. Submit each step separately.
-
Delete the original vector index
SET odps.sql.type.system.odps2=true; SET odps.sql.type.vector.enable=true; DROP INDEX doc_vector_index ON TABLE doc_table; -
Re-create the index and adjust
bucket_num_per_index_fileSET odps.sql.type.system.odps2=true; SET odps.sql.type.vector.enable=true; CREATE VECTOR INDEX doc_vector_index ON doc_table (embedding) IDXPROPERTIES ( 'algorithm' = 'hgraph', 'distance_type' = 'cosine', 'bucket_num_per_index_file' = '4', 'build_params' = '{"max_degree":16,"ef_construction":128,"base_quantization_type":"fp16"}' );Parameter
bucket_num_per_index_file: The default value is1. In this example, the parameter is set to4, which indicates that each index file contains 4 buckets. The numbers of index files and Workers and the corresponding resource requests are reduced to approximately1/4of their original values.The value
4is an optimization example for scenarios with insufficient resources, not a fixed value for all jobs. Reducing the number of Workers reduces resource requests but also reduces search parallelism. Therefore, performance typically degrades when sufficient resources are available. -
Rebuild the index
SET odps.sql.type.system.odps2=true; SET odps.sql.type.vector.enable=true; ALTER TABLE doc_table REBUILD INDEX doc_vector_index; -
Verify the index status
SET odps.sql.type.system.odps2=true; SHOW INDEXES ON doc_table;Confirm that the new index has taken effect, and then resubmit the original vector search job.
Verification: After rerunning the query, check the
AnnIndexScanstage in LogView. The planned number of Workers should decrease significantly, the Workers should start normally, and the job should no longer continue to wait for resources. If the job remains stalled, check the available resources in the current Quota and increasebucket_num_per_index_fileas appropriate.
Slow vector index build
-
Typical symptom: When
REBUILD INDEXis run to build a vector index, the build stage runs normally but takes a long time. -
Default configuration: The default value of
odps.sql.vector.index.build.coresis4. If this parameter is not set, each index build Worker uses 4 CPU cores by default. Explicitly setting the parameter to4does not provide additional acceleration. -
Resource and performance changes after adjustment: Increasing the number of CPU cores for building from the default value
4to8can increase the processing capability of each build Worker, but also doubles its CPU request. The build duration does not necessarily decrease in proportion to the number of cores. If Quota resources are insufficient, the job may become slower while waiting for resources.
Determine whether to increase CPU cores
Confirm in LogView that the index build stage has started and continues to run. If most of the time is spent waiting for resources, address the Quota resource shortage first. Increase the number of CPU cores for building only if the build stage itself runs slowly.
Solution
Place odps.sql.vector.index.build.cores and the actual REBUILD INDEX operation in the same submission. The following example increases the CPU cores for each index build Worker from the default value of 4 to 8:
SET odps.sql.type.system.odps2=true;
SET odps.sql.type.vector.enable=true;
SET odps.sql.vector.index.build.cores=8;
ALTER TABLE doc_table
REBUILD INDEX doc_vector_index;
Parameterodps.sql.vector.index.build.cores: Controls the number of CPU cores used by each index build Worker. The default value is 4, and the maximum value is 16. In this example, the parameter is set to 8. Adjust the value based on the data volume and available Quota.
Important: Setting the parameter to 4 is equivalent to using the default configuration and does not accelerate the build. This parameter does not modify build jobs that are already running. Do not run SET in a separate session and then submit REBUILD INDEX separately. Otherwise, the new value may not be applied to the actual build job. An excessively large value may also increase the queueing time.
Verification: Confirm in LogView that the build Worker obtained the specified number of CPU cores, and record the resource wait time, build-stage duration, and total duration separately. The adjustment is effective only if the build-stage duration decreases without a significant increase in queueing time.
Slow vector index search
-
Typical symptom: The job uses a persistent vector index, and the
AnnIndexScanWorkers run normally, but the search stage takes a long time. -
Optimization principle: First determine whether the issue is insufficient processing capacity on the index Server, insufficient request supply on the Query side, or slow result merging and writing. The number of index Workers, the number of search threads per Worker, and the number of Query Workers are three different types of concurrency and cannot be adjusted with a single parameter.
Identify the bottleneck
|
LogView symptom |
Diagnosis |
Recommended action |
|
|
Resources are insufficient. Search computation is not slow. |
Reduce the numbers of index files and Workers as described in section 1, or increase the available Quota |
|
The index Server CPU utilization is high, and the Query side continuously waits for responses |
The index Server is the bottleneck |
Increase the number of search threads per Server if the Quota allows. Reconsider the number of index Workers if necessary. |
|
The index Server CPU utilization is low, and the number of Query Workers is small or requests are intermittent |
The Query side does not supply enough requests |
Increase scan split concurrency for the Query table |
|
The vector search stage has ended, but downstream processing still takes a long time |
Candidate merging or result writing is the bottleneck |
Check TopK, output columns, the number of result rows, and downstream operators. Do not continue to increase search threads without analysis. |
Method 1: Adjust the search capacity of each index Server
The following parameter and the actual VECTOR_SEARCH query must be placed in the same submission. This example configures 2 search threads for each index Server and requests resources based on approximately 1 CPU core per search thread:
SET odps.sql.type.system.odps2=true;
SET odps.sql.type.vector.enable=true;
SET odps.sql.vector.search.service.thread.count=2;
-- Run the actual VECTOR_SEARCH query in the same submission
|
Parameter |
Function |
Impact of increasing or decreasing the value |
|
|
Specifies the number of search threads for each index Server Worker, not the total number of CPU cores for the entire job. |
A larger value allows each Server to process more requests in parallel but also increases the CPU request and thread contention for each Server. If Query requests are insufficient, increasing the value typically provides no benefit. |
For example, 16 index Servers with 2 threads each require approximately 32 CPU cores on the index Server side alone. Resources must also be reserved for the Query, merge, and write stages.
Important: Increasing service.thread.count does not increase the number of index Server Workers. The number of Workers is mainly determined by the buckets of the base table and the index file layout. If many Workers already exist, further increasing the number of threads may degrade performance because of Quota queueing or CPU contention.
Method 2: Increase concurrency on the Query side
If the index Server still has idle CPU resources and the number of Query Workers is small, set the scan split size based on the number of rows in the Query table, provided that the current environment and table type support this setting:
SET odps.sql.type.system.odps2=true;
SET odps.sql.type.vector.enable=true;
SET odps.sql.split.row.count={"project_name.query_table":600000};
-- Run the actual VECTOR_SEARCH query in the same submission
|
Parameter |
Function |
Calculation and risks |
|
|
Specifies the target number of rows in each scan split for a table. A smaller value typically generates more Query Workers, which send requests to the index Server more continuously. |
|
The key in the parameter must use the fully qualified table name that is actually scanned in the execution plan, such as project_name.query_table. After setting the parameter, confirm in LogView that the number of Query Workers has changed. The target number of splits is not equal to the number of Workers that run concurrently. Actual concurrency is still limited by the file layout and Quota.
Method 3: Adjust the index layout
If a single index Server remains fully loaded and the Quota still has available capacity, increase the number of index Server Workers. However, more index shards do not always improve performance. Each Query must access more index Servers and merge more candidates. The additional RPC and merge overhead may offset the benefits of parallelism.
Establish a baseline with a small number of Workers, and then test in increments of 1 → 2 → 4 or similar. For searches with category conditions, distribute and sort the base data by the category field to prevent a single bucket from containing too many hot categories. Rebuild the vector index after changing the layout.
Result volume also affects performance
A larger TopK increases the amount of data returned by the index Server, the number of candidates merged across shards, and the final output volume. Select only the IDs, distances, and other fields required for the use case. Do not include the vector column in the results again. If global sorting is not required, do not add an extra ORDER BY.
Verification: Adjust only one primary variable at a time, and write the results of different tests to separate result tables or partitions. Compare the actual number of Server Workers, CPU usage of each Server, number of Query Workers, resource wait time, search-stage duration, merge and write duration, and end-to-end duration in LogView. If the duration decreases but resource usage increases significantly, determine whether the adjustment is worthwhile based on the Quota and resource cost.