Choose an index type
seekdb provides various vector indexes with different algorithms. You can choose an appropriate 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 cache is sufficient and can operate without relying on memory. However, choosing between HNSW and IVF is not solely based on memory considerations. Business scenarios, data volume, performance metrics, and resource constraints must all be considered. The following sections compare their core differences and provide recommendations for selection.
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, millisecond-level response | High, nearly comparable to HNSW when cache is sufficient |
| Recall Rate | High, up to 99% | High, slightly lower than HNSW, can be optimized through parameters |
| Build Speed | Slower, requires building the graph structure | Faster, based on clustering algorithms |
| Applicable Data Volume | Millions to billions | Millions to tens of billions |
| Cost | High memory cost | Low storage cost, suitable for large-scale data |
| Real-time Support | Supports real-time DML operations | Supports real-time DML operations |
Decision Flowchart
- Before selecting an index type, you need to estimate the memory usage based on Vector Index Memory Management.
- The recommendations in the decision flowchart are based on 1024-dimensional vectors. If the actual dimensions differ, 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 sufficient memory, it's not always optimal to choose the highest specification indexes like HNSW. If you have high performance requirements, consider cost-effective options like HNSW_SQ.

This section lists only some common scenarios. If you cannot determine the index type based on the above flowchart or have other requirements, please contact seekdb Technical Support.
Should I use partitioned tables?
The primary purpose of using partitioned tables is to handle large-scale data scenarios. Additionally, if the query conditions can be used as partition keys, partition pruning can enhance query performance. We recommend using partitioned tables in the following scenarios:
- The data volume reaches tens of millions or even hundreds of millions: When the data volume is very large, using partitioned tables can distribute the data across multiple partitions, with each partition independently building an index. This reduces the load of a single query and improves overall query performance.
- The query conditions contain scalar columns that can be used for partition pruning: For example, if the
labelfield always appears in theWHEREcondition, you can consider creating a partitioned table withlabelas the partition key. This reduces the number of partitions to be queried through partition pruning.
Specific recommendations are as follows:
Partitioning
When using vector indexes, the number of partitions should not be excessive. Unlike scalar indexes, vector indexes (such as HNSW) do not significantly increase the computational overhead for querying the TopK results when the index size increases from 1 million to 2 million vectors under the same configuration. Therefore, if partition pruning cannot be utilized, having too many partitions may actually degrade performance. Additionally, a single partition that is too large not only increases the time required for index rebuilding but also affects the efficiency of joint queries with scalar conditions.
In summary, we recommend keeping the data volume in each partition below 20 million and preferentially selecting fields that support partition pruning as the partition key.
Algorithm Selection
For large-scale data, we recommend using the HNSW_BQ or IVF_PQ index. If you need to use other indexes, refer to the Memory Usage section for estimation.
Memory Usage
HNSW_BQ
For the HNSW_BQ index, configure vector_memory_limit so that it is greater than the total memory required for HNSW_BQ queries plus the memory required by the HNSW_SQ index for one partition. Make sure that memory_budget can accommodate this vector-memory allocation together with the other instance modules. Estimate the required memory as follows:
- First, use the
INDEX_VECTOR_MEMORY_ADVISORfunction to calculate the recommended memory values for the HNSW_BQ and HNSW_SQ indexes during construction and query. - Use the recommendation to determine
vector_memory_limitand the totalmemory_budgetrequired by the instance.
For example, if you have 100 million 1024-dimensional vector data across 10 partitions (approximately 10 million vectors per partition), 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 construction and query.
-- This eliminates the need for separately calculating the memory usage of the HNSW_SQ index. This is because the HNSW_BQ index is constructed using the SQ8 quantization algorithm by default.
-- After specifying refine_type=sq8, the function automatically includes the memory required for the SQ8 quantized vectors in the calculation.
-- 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
-- By default, vector_memory_limit is 50% of memory_budget. Therefore, the required memory budget is
SELECT 74.6/0.5;
+--------------------------------------------------------------------------------------------------------------+
| 74.6/0.5 = 149.2 GB |
+--------------------------------------------------------------------------------------------------------------+
1 row in set
-- Considering that new data may not be 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, it is recommended to configure memory_budget as 179 GB.
IVF Series
For IVF and IVF_PQ indexes, configure vector_memory_limit so that it is greater than the memory required to build one partition plus the total resident memory required by all partitions. The following example uses distance=cosine: with 100 million rows and 10 partitions (approximately 10 million vectors per partition), building one partition requires about 2.7 GB, and each partition requires about 11.4 MB of resident memory during queries, or about 114 MB in total. Therefore, vector_memory_limit must be at least approximately 2.9 GB; after reserving headroom, 6 GB is recommended. If you keep vector_memory_limit=0M, its effective value is 50% of memory_budget, so a 6 GB vector-memory limit requires at least a 12 GB memory_budget, with additional capacity reserved for other modules. For distance=l2, building one partition requires about 4.0 GB and each partition requires about 1.3 GB of resident memory, or about 13 GB for 10 partitions. In that case, vector_memory_limit must be at least approximately 17 GB, and the preceding 6 GB recommendation does not apply. Other data volumes can be estimated in the same way.
Construction and Query Parameters
We recommend setting the index construction and query parameters based on the maximum data volume of a single partition. For more details, see the Index Parameter Recommendations section.
Performance and Recall Rate
- If the query conditions can prune to a single partition: The performance and recall rate are the same as in the single-partition scenario. For more details, see the section on different data volume scales.
- If the query conditions cannot prune to a single partition: The QPS can be estimated proportionally based on the number of partitions per OBServer node (e.g., if a single node contains 3 partitions, the QPS is approximately one-third of the single-partition performance). Since cross-partition queries merge more candidate results, the actual recall rate is typically higher than in the single-partition scenario.
Index parameter recommendations
HNSW series
The recommended index construction and query parameters vary depending on the data volume within the same series. This section provides suggested configurations for 768-dimensional vectors with 1 million and 10 million data points for HNSW, HNSW_SQ, and HNSW_BQ indexes. For vector data in the billions, refer to the subsequent sections of this document for IVF_PQ indexes or HNSW_BQ indexes within partitioned tables.
- For scenarios where data volume is expected to grow, it is recommended to set parameters based on the final data volume.
- HNSW_BQ is a high-compression quantization algorithm. The recall rate may be relatively low 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 | 1 million data points: m = 16, ef_construction = 200, ef_search = 100, other parameters default |
| Highest Performance (Lowest memory usage) | HNSW_SQ | 1 million data points: m = 16, ef_construction = 200, ef_search = 100, other parameters default 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 | 1 million data points: m = 16, ef_construction = 200, ef_search = 100, other parameters default 10 million data points: m = 32, ef_construction = 400, ef_search = 1000, refine_k = 10, other parameters default 1 billion data points: Use partitioned tables, m = 32, ef_construction = 400, ef_search = 1000, refine_k = 10, other parameters default |
Detailed Explanation for 1 Million Data Points
Take 1 million 768-dimensional vectors as an example (using the construction parameters from the table above). Additional details on memory usage and recall rate optimization are provided below:
Memory Usage:
| Index Type | Recommended memory_budget | Description |
|---|---|---|
| HNSW | 15 GB | The recommended vector index memory is 7.3 GB. With vector_memory_limit=0M, the vector module can use 50% of memory_budget, so a memory budget of approximately 15 GB is required. |
| HNSW_SQ | 6 GB | The recommended size for the vector index is 2.1 GB. |
| HNSW_BQ | 6 GB | HNSW_BQ requires high-precision vectors while the index is being built, so its build-time memory requirement is the same as HNSW_SQ: 6 GB. HNSW_BQ uses SQ8 quantization by default. After the index is built, memory usage decreases significantly to about 405 MB. This estimate applies to a non-partitioned table. For a partitioned table, seekdb dynamically adjusts the number of partitions built concurrently according to vector_memory_limit. Configure enough vector memory for HNSW_BQ queries and for the HNSW_SQ memory required to build one partition, with additional headroom. For the calculation method, see Memory Usage 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 calculations, but this will also reduce query performance. You can set the parameters 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 values higher.
The recall rate is directly related to the data characteristics. The following table provides the recommended values for a standard dataset of 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 |
Extreme Recall Rate:
The maximum recall rates vary among different indexing algorithms. When using the recommended construction parameters from this section and setting ef_search to 1000, the query recall rate may improve, but the QPS will drop to one-third of the value at a 0.95 recall rate. Increasing ef_search does not guarantee an unlimited increase in recall rate for all index types. Only HNSW can achieve a recall rate of 0.99 or higher. For HNSW_BQ, you can further increase the refine_k parameter to improve the recall rate, but this will also result in a decrease in performance.
Extreme 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 Explanation for 10 Million Data Points
Take 10 million 768-dimensional vectors as an example (using the construction parameters from the table above). Additional details on memory usage and recall rate optimization are provided below:
Memory Usage:
| Index Type | Recommended memory_budget | Description |
|---|---|---|
| HNSW | 160 GB | The recommended size for the vector index is 76.3 GB. |
| HNSW_SQ | 48 GB | The recommended size for the vector index is 22.6 GB. |
| HNSW_BQ | 48 GB | During construction, HNSW_BQ requires high-precision vectors. By default, 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 HNSW_SQ. After construction, the HNSW_BQ index 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 calculations, but this will also reduce query performance. You can set the parameters 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 values higher.
The recall rate is directly related to the data characteristics. The following table provides the recommended values for a standard dataset of 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-dimensional (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 for vectors with 128 dimensions or more.
- For scenarios where the data volume is expected to grow, it is recommended to set the parameters based on the final data volume.
10 million data volume (with partitioned tables)
For example, for 10 million vectors with 768 dimensions (using the construction parameters in the table above), additional explanations on memory usage and recall rate optimization are provided:
Memory usage:
| Index Type | Index Parameters | Memory Usage (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 during index creation, which is released after construction; Resident Overhead refers to the memory continuously occupied by the IVF vector index after construction.
For IVF_PQ indexes, if you choose distance=l2, more resident memory will be occupied due to the need to store additional precomputed results. In contrast, using distance=inner_product or cosine typically consumes less resident memory. 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 values in the table below are recommended for a standard dataset with 768 dimensions to achieve a recall rate of around 0.95.
| 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, the query load can be effectively reduced. Additionally, parallel queries across partitions can further improve overall query performance and recall rate.
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 vectors with 768 dimensions split into 10 partitions, each partition contains about 10 million vectors, and nlist is recommended to be sqrt(10 million) = 3162.
For example, for 100 million vectors with 768 dimensions (using the construction parameters in the table above), additional explanations on memory usage and recall rate optimization are provided:
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 is approximately 10.5 × 10 = 105 MB.
| Index Type | Index Parameters | Memory Usage (Construction Overhead / Resident Overhead) |
|---|---|---|
| IVF | distance=l2, nlist=3000 | 2.7 GB / 10.5 MB × 10 |
| IVF_PQ | distance=l2, nlist=3000, m=384 | 4.0 GB / 1.3 GB × 10 |
| IVF_PQ | distance=cosine, nlist=3000, m=384 | 2.7 GB / 11.4 MB × 10 |
In the table, Construction Overhead refers to the temporary memory occupied during index creation, which is 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, TopN results will be retrieved from each partition and then aggregated and re-ranked. This not only improves overall search accuracy but also typically results in a higher actual 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 in single-partition tables.
Recall rate is directly related to data characteristics. The values in the table below are recommended for a standard dataset with 768 dimensions to achieve a recall rate of around 0.95.
| TopN | nprobes |
|---|---|
| Top10 | 1 |
| Top100 | 10 |
References
- For more information about parameters and tuning, see HNSW Index and IVF Index.