Choose an index type
seekdb provides various vector indexes with different algorithms. You can choose an index type based on your use case.
HNSW or IVF?
The dense indexes of seekdb are divided into two major categories:
- Graph-based HNSW series indexes: HNSW, HNSW_SQ, and HNSW_BQ.
- Disk-based IVF series indexes: IVF and IVF_PQ.
Each type of index has its own strengths. HNSW series indexes typically offer higher query performance but require more memory. IVF series indexes perform well when caching is sufficient and do not rely on memory. However, the choice between HNSW and IVF is not solely based on memory considerations. It should be evaluated from multiple dimensions, including business scenarios, data volume, performance metrics, and resource constraints. The following sections will detail the core differences and provide recommendations.
Core Differences
| Dimension | HNSW Series | IVF Series |
|---|---|---|
| Storage Method | Memory-based graph structure index | Disk-based index |
| Memory Usage | Requires full memory loading, high memory usage | Does not require memory, low memory usage |
| Query Performance (QPS) | Extremely high, sub-millisecond response | High, close to HNSW when caching is sufficient |
| Recall Rate | High, up to 99% | High, slightly lower than HNSW, can be optimized with parameters |
| Build Speed | Slower, requires graph structure building | Faster, based on clustering algorithms |
| Applicable Data Volume | Millions to hundreds of millions | Millions to billions |
| Cost | High memory cost | Low storage cost, suitable for large-scale data |
| Real-time | Supports real-time DML operations | Supports real-time DML operations |
Decision Flowchart
- Before selecting an index type, refer to Vector Index Memory Management to estimate memory usage.
- The recommendations in the decision flowchart are based on 1024-dimensional vectors. If the actual dimensionality differs, you can approximately calculate the required resources based on the proportion.
- The decision flowchart primarily considers memory costs to help you choose an index type.
- Even with ample memory, it's not always optimal to choose the highest specification index like HNSW. If you require extreme performance, consider cost-effective options like HNSW_SQ.

This section only covers some common scenarios. If you cannot determine the index type through the above flowchart or have other requirements, please contact seekdb Technical Support.
Use partitioned tables?
The primary purpose of using partitioned tables is to handle large-scale data scenarios. Additionally, if query conditions can be used as partition keys, partition pruning can improve query performance. We recommend that you use partitioned tables in the following two scenarios:
- The data volume reaches tens of millions or even hundreds of millions of rows: When the data volume is very large, using partitioned tables can disperse the data to multiple partitions. Each partition independently builds an index, thereby reducing the load of a single query and improving overall query performance.
- The query conditions contain scalar columns that can be used for partition pruning: For example, if the
labelfield always appears in theWHEREclause, you can consider creating a partitioned table withlabelas the partition key. This way, you can reduce the number of partitions to query by using partition pruning.
The following recommendations are provided:
Partitioning
When using vector indexes, do not use too many partitions. Unlike scalar indexes, vector indexes (such as HNSW) do not significantly increase the computational overhead required to query the TopK results when the index size increases from 1 million to 2 million vectors under the same configuration. Therefore, if you cannot use partition pruning, using too many partitions may reduce performance. In addition, a single partition that is too large not only increases the time required to rebuild the index but also affects the efficiency of joint queries with scalar conditions.
In summary, we recommend that you keep the data volume in each partition below 20 million and prioritize selecting a field that supports partition pruning as the partition key.
Algorithm selection
We recommend that you use the HNSW_BQ or IVF_PQ index for large-scale data. If you need to use other indexes, refer to the Memory usage section for estimation.
Memory usage
HNSW_BQ
For the HNSW_BQ index, we recommend that you set memory > HNSW_BQ query memory + memory occupied by the HNSW_SQ index in a single partition. The memory estimation process is as follows:
- Use the
INDEX_VECTOR_MEMORY_ADVISORfunction to calculate the recommended memory values for the HNSW_BQ and HNSW_SQ indexes during index building and query. - Based on the recommended memory values obtained from the above tool, calculate and determine the total required memory.
For example, assume that you have 100 million 1024-dimensional vector data, and you use 10 partitions (each partition contains about 10 million vectors). The calculation process is as follows:
-- Specify REFINE_TYPE=SQ8 to directly and accurately obtain the recommended memory values for the HNSW_BQ index during index building and query.
-- You do not need to separately calculate the memory occupied by the HNSW_SQ index. This is because the HNSW_BQ index is built using the SQ8 quantization algorithm by default.
-- After specifying refine_type=sq8, the function automatically calculates the memory required for the SQ8 quantization vectors during index building.
-- The recommended memory value for the HNSW_BQ index is 74.6 GB, and the memory consumption during query is 57.4 GB. We use the recommended memory value.
SELECT DBMS_VECTOR.INDEX_VECTOR_MEMORY_ADVISOR('HNSW_BQ',100000000,1024,'FLOAT32','M=32,DISTANCE=COSINE,REFINE_TYPE=SQ8', 10000000);
+------------------------------------------------------------------------------------------------------------------------------+
| DBMS_VECTOR.INDEX_VECTOR_MEMORY_ADVISOR('HNSW_BQ',100000000,1024,'FLOAT32','M=32,DISTANCE=COSINE,REFINE_TYPE=SQ8', 10000000) |
+------------------------------------------------------------------------------------------------------------------------------+
| Suggested minimum vector memory is 74.6 GB, memory consumption when providing search service is 57.4 GB |
+------------------------------------------------------------------------------------------------------------------------------+
1 row in set
-- The default memory occupancy of vectors in memory is 50%. Therefore, the total memory is
SELECT 74.6/0.5;
+--------------------------------------------------------------------------------------------------------------+
| 74.6/0.5 = 149.2 GB |
+--------------------------------------------------------------------------------------------------------------+
1 row in set
-- To account for the possibility that new data is not compressed in the actual environment, we recommend reserving some redundancy.
SELECT 149.2 * 1.2;
+--------------------------------------------------------------------------------------------------------------+
| 149.2 * 1.2 = 179.04 GB |
+--------------------------------------------------------------------------------------------------------------+
1 row in set
-- Therefore, we recommend that you set the memory to 179 GB.
IVF series
For the IVF and IVF_PQ indexes, we recommend that you set memory > memory required to build a single partition + total memory occupied by all partitions. For example, if you have 100 million data rows and use 10 partitions (each partition contains about 10 million vectors), the memory required to build a single partition is about 2.7 GB, and the total memory occupied by the IVF_PQ indexes in all partitions during query is about 1.1 GB (110 MB per partition). Therefore, the minimum required memory is about 3 GB. We recommend that you reserve some redundancy and set the memory to 6 GB. You can estimate the memory required for other data volume scenarios using the same method.
Index building and query parameters
We recommend that you set the index building and query parameters based on the maximum data volume in a single partition. For more information, see the Index parameter recommendations section.
Performance and recall rate
- If the query conditions can prune the data to a single partition: The performance and recall rate are consistent with those in a single partition scenario. For more information, see the sections that describe the performance and recall rate for different data volumes.
- If the query conditions cannot prune the data to a single partition: The QPS can be estimated proportionally based on the number of partitions in a single OBServer node (for example, if a single node contains 3 partitions, the QPS is about 1/3 of the performance in a single partition). The actual recall rate is usually higher than that in a single partition scenario because cross-partition queries merge more candidate results.
Index parameter recommendations
HNSW series
The recommended index construction and query parameters vary depending on the data volume for indexes in the same series. This section provides recommended configurations for 768-dimensional vectors with 1 million and 10 million data points for HNSW, HNSW_SQ, and HNSW_BQ indexes. For 100 million data points, refer to the subsequent sections of this topic for IVF_PQ or HNSW_BQ indexes under partitioned tables.
- For scenarios where the data volume is expected to grow, it is recommended to set the parameters based on the final data volume.
- HNSW_BQ is a high-compression quantization algorithm. The recall rate may be limited in low-dimensional vectors. To avoid performance loss, it is recommended to use HNSW_BQ for vectors with 512 dimensions or more.
| Scenario | Index Type | Parameter Recommendations |
|---|---|---|
| Maximum Recall (Highest memory usage) | HNSW | For 1 million data points: m = 16, ef_construction = 200, ef_search = 100, other parameters default |
| Maximum Performance (Lowest memory usage) | HNSW_SQ | For 1 million data points: m = 16, ef_construction = 200, ef_search = 100, other parameters default For 10 million data points: m = 32, ef_construction = 400, ef_search = 350, other parameters default |
| Best Cost-Performance (Low memory usage, good performance) | HNSW_BQ | For 1 million data points: m = 16, ef_construction = 200, ef_search = 100, other parameters default For 10 million data points: m = 32, ef_construction = 400, ef_search = 1000, refine_k = 10, other parameters default For 100 million data points: Use partitioned tables, m = 32, ef_construction = 400, ef_search = 1000, refine_k = 10, other parameters default |
Detailed information for 1 million data points
For example, consider 1 million 768-dimensional vectors (using the construction parameters from the table above), and additional details on memory usage and recall rate optimization:
Memory Usage:
| Index Type | Recommended Memory | Description |
|---|---|---|
| HNSW | 15 GB | The recommended memory size for the vector index is 7.3 GB. When the memory exceeds 8 GB, the vector index will use up to 50% of the available memory by default. When the memory is 8 GB or less, the vector index will use up to 40% of the available memory by default. Therefore, approximately 15 GB of memory is required. |
| HNSW_SQ | 6 GB | The recommended memory size for the vector index is 2.1 GB. |
| HNSW_BQ | 6 GB | HNSW_BQ indexes require high-precision vectors during construction, so the memory requirements are the same as HNSW_SQ, which is 6 GB. HNSW_BQ indexes use the SQ8 quantization method by default. After the index is built, the memory usage significantly decreases to about 405 MB. The above information applies to non-partitioned tables. If you use partitioned tables, seekdb will dynamically adjust the number of partitions that can be built simultaneously based on the allocated memory. When configuring, it is recommended to include at least the memory required for HNSW_BQ queries and the memory required for HNSW_SQ during the construction of a partition, with some redundancy. For specific calculation methods, please refer to the Memory Usage section above. |
Recall Rate Optimization:
By adjusting the ef_search and refine_k (only for HNSW_BQ) parameters, you can increase the recall rate through more vector computations, but this will also reduce query performance. You can set the parameters to the recommended values in the table below for different TopN values. If you need to further improve the recall rate, you can set the parameter values to be larger.
The recall rate is directly related to the data characteristics. The following table provides the recommended values for a standard dataset with 768 dimensions, where the recall rate reaches approximately 0.95.
| TopN | ef_search | refine_k (only for HNSW_BQ) |
|---|---|---|
| Top10 | 64 | 4 |
| Top100 | 240 | 4 |
Maximum Recall Rate:
The maximum recall rates of different index algorithms vary. Under the recommended construction parameters in this section, setting ef_search to 1000 may improve the query recall rate, but the QPS will decrease to one-third of the value at a 0.95 recall rate. Increasing ef_search does not necessarily lead to an infinite improvement in recall rate for all index types. Only HNSW can achieve a recall rate of 0.99 or higher. You can further increase the refine_k parameter to improve the recall rate of the HNSW_BQ index, but this will also lead to a decrease in performance.
Maximum Recall Rate Reference Values (ef_search = 1000):
- HNSW Index: Recall Rate 0.991
- HNSW_SQ Index: Recall Rate 0.9786
- HNSW_BQ Index: Recall Rate 0.9897 (ef_search = 1000, refine_k = 10)
Detailed information for 10 million data points
For example, consider 10 million 768-dimensional vectors (using the construction parameters from the table above), and additional details on memory usage and recall rate optimization:
Memory Usage:
| Index Type | Recommended Memory | Description |
|---|---|---|
| HNSW | 160 GB | The recommended memory size for the vector index is 76.3 GB. |
| HNSW_SQ | 48 GB | The recommended memory size for the vector index is 22.6 GB. |
| HNSW_BQ | 48 GB | HNSW_BQ indexes require high-precision vectors during construction. HNSW_BQ uses HNSW_SQ as the cache during index construction. Therefore, for non-partitioned tables, the memory required for HNSW_BQ is the same as that for HNSW_SQ. After the index is built, HNSW_BQ only occupies about 5.4 GB of memory. |
Recall Rate Optimization:
By adjusting the ef_search and refine_k (only for HNSW_BQ) parameters, you can increase the recall rate through more vector computations, but this will also reduce query performance. You can set the parameters to the recommended values in the table below for different TopN values. If you need to further improve the recall rate, you can set the parameter values to be larger.
The recall rate is directly related to the data characteristics. The following table provides the recommended values for a standard dataset with 768 dimensions, where the recall rate reaches approximately 0.95.
| TopN | ef_search | refine_k (only for HNSW_BQ) |
|---|---|---|
| Top10 | 100 | 4 |
| Top100 (HNSW/HNSW_SQ) | 350 | - |
| Top100 (HNSW_BQ) | 1000 | 10 |
IVF series
| Scenario | Index type | Parameter recommendation |
|---|---|---|
| Low dimension (384 dimensions or less) | IVF | For 10 million data: use partitioned tables, nlist=3000 For 100 million data: use partitioned tables, nlist=3000 |
| Low cost (minimal memory usage) | IVF_PQ | For 1 million data: nlist=1000, m=vector dimension / 2 For 10 million data: nlist=3000, m=vector dimension / 2 For 100 million data: use partitioned tables, nlist=3000, m=vector dimension / 2 |
To balance the number of cluster centers and the amount of data per center, it is generally recommended to set nlist to the square root of the data volume. For example, for 10 million data, nlist is recommended to be around 3000. When using IVF_PQ, the m parameter is recommended to be half of the vector dimension.
- IVF_PQ is a high-compression quantization algorithm. In low-dimensional vectors, the recall rate may be relatively low. To avoid performance loss, it is recommended to use IVF_PQ on vectors with 128 dimensions or more.
- For scenarios where the data volume is expected to grow, it is recommended to set parameters based on the final data volume.
10 million data volume (with partitioned tables)
Take 10 million 768-dimensional vector data as an example (using the construction parameters in the table above), and provide additional details on memory usage and recall rate optimization:
Memory usage:
| Index type | Index parameter | Memory overhead (construction overhead / resident overhead) |
|---|---|---|
| IVF | distance=l2, nlist=3000 | 2.7 GB / 10.5 MB |
| IVF_PQ | distance=l2, nlist=3000, m=384 | 4.0 GB / 1.3 GB |
| IVF_PQ | distance=cosine, nlist=3000, m=384 | 2.7 GB / 11.4 MB |
In the table, construction overhead refers to the temporary memory occupied by the index during creation, which will be released after construction; resident overhead refers to the memory continuously occupied by the IVF vector index after construction.
For IVF_PQ indexes, if distance = l2 is selected, more resident memory will be occupied due to the need to store additional precomputed results. In contrast, using distance = inner_product or cosine typically results in lower resident memory consumption. Therefore, in practical applications, it is recommended to prioritize inner_product or cosine as the distance type to optimize memory resources.
Recall rate optimization:
By adjusting the nprobes parameter, you can increase the recall rate through more vector calculations, but this will also reduce query performance. You can set the parameter to the recommended values in the table below for different TopN scenarios. If you need to further improve the recall rate, you can set the parameter value to a larger value.
Recall rate is directly related to data characteristics. The table below provides the recommended values for achieving a recall rate of approximately 0.95 on a standard 768-dimensional dataset.
| TopN | nprobes |
|---|---|
| Top10 | 1 |
| Top100 | 20 |
100 million data volume (with partitioned tables)
When the vector data volume reaches 100 million or more, it is strongly recommended to use partitioned tables combined with IVF-type indexes. As the data scale and nlist parameter increase, the query overhead of a single IVF index will also significantly increase. By splitting the data into multiple partitions and building smaller-scale IVF indexes for each partition, you can effectively reduce the query load and further improve overall query performance and recall rate through parallel queries across partitions.
In multi-partition table scenarios, since IVF indexes are local, each partition will independently build its own IVF index. Therefore, it is recommended to calculate the nlist value based on the average data volume of each partition. For example, for 100 million 768-dimensional vectors split into 10 partitions, each partition contains approximately 10 million vectors, and nlist is recommended to be sqrt(10 million) = 3162.
Take 100 million 768-dimensional vector data as an example (using the construction parameters in the table above), and provide additional details on memory usage and recall rate optimization:
Memory usage:
In multi-partition scenarios, since IVF indexes are local, each partition will independently build and maintain its own IVF index. Therefore, the total resident memory usage must be summed across all partitions. For example, in the table below, the resident memory of a single IVF index is 10.5 MB. If there are 10 partitions, the total resident memory would be approximately 10.5 × 10 = 105 MB.
| Index type | Index parameter | Memory overhead (construction overhead / resident overhead) |
|---|---|---|
| IVF | distance=l2, nlist=3000 | 2.7 GB / 10.5 * 10 MB |
| IVF_PQ | distance=l2, nlist=3000, m=384 | 4.0 GB / 1.3 * 10 GB |
| IVF_PQ | distance=cosine, nlist=3000, m=384 | 2.7 GB / 11.4 * 10 MB |
In the table, construction overhead refers to the temporary memory occupied by the index during creation, which will be released after construction; resident overhead refers to the memory continuously occupied by the IVF vector index after construction.
Recall rate optimization:
By adjusting the nprobes parameter, you can increase the recall rate through more vector calculations, but this will also reduce query performance. You can set the parameter to the recommended values in the table below for different TopN scenarios. If you need to further improve the recall rate, you can set the parameter value to a larger value.
In partitioned table scenarios, since each partition will independently execute IVF index queries, when querying across multiple partitions, the system will retrieve TopN results from each partition and then aggregate and re-sort all the results. This not only improves the overall search accuracy but also typically results in a higher recall rate compared to single-partition scenarios. Therefore, in multi-partition tables, you can appropriately reduce the nprobes parameter to achieve a recall rate comparable to that of single-partition tables.
Recall rate is directly related to data characteristics. The table below provides the recommended values for achieving a recall rate of approximately 0.95 on a standard 768-dimensional dataset.
| TopN | nprobes |
|---|---|
| Top10 | 1 |
| Top100 | 10 |
References
- For more information about parameters and tuning, see HNSW Index and IVF Index.