Skip to main content
Version: V1.1.0

Store vector data

This topic describes how to store unstructured, semi-structured, and structured data in seekdb. This approach not only fully utilizes the basic capabilities of seekdb but also provides strong support for hybrid search.

Storage principles​

seekdb can store data of different modalities and supports hybrid search. The principle of hybrid search is to convert data of different modalities (such as text, images, and videos) into vectors and then search based on the distance between vectors. Hybrid search can be divided into two types: simple search, which is based on the similarity of a single vector, and complex search, which involves the hybrid search of vectors and scalars.

Because vector search is approximate, you must combine it with other methods to improve accuracy in practical applications. Accurate search results can provide greater value for your business.

Configure vector index memory​

You can configure the memory of vector indexes by setting the ob_vector_memory_limit_percentage parameter for vector search:

The default value of this parameter is 0, which indicates adaptive mode. In adaptive mode, the system automatically adjusts the memory usage ratio of vector index data in an instance. You do not need to manually adjust this parameter:

  • If the actual memory of an instance is 8 GB or less, the value is automatically adjusted to 40.
  • If the actual memory of an instance is more than 8 GB, the value is automatically adjusted to 50.

Create a vector column​

The following example shows a table that stores vector data, spatial data, and relational data. The data type of the vector column is VECTOR, and the dimension must be specified when the column is created. The maximum supported dimension is 16000. The data type of the spatial column is GEOMETRY:

CREATE TABLE t (
-- Store relational data (structured data)
id INT PRIMARY KEY,
-- Store spatial data (semi-structured data)
g GEOMETRY,
-- Store vector data (unstructured data)
vec VECTOR(3)
);

Insert vector data by using the INSERT statement​

After you create a table that contains a column of the VECTOR data type, you can directly use the INSERT statement to insert vectors into the table. When you insert data, the vectors must match the dimensions specified when the table was created. Otherwise, an error is returned. This design ensures data consistency and query efficiency. Vectors are represented as standard floating-point number arrays, and the values of each dimension must be valid floating-point numbers. The following example shows how to insert data into the table:

INSERT INTO t (id, g, vec) VALUES (
-- Insert structured data
1,
-- Insert semi-structured data
ST_GeomFromText('POINT(1 1)'),
-- Insert unstructured data
'[0.1, 0.2, 0.3]'
);

References​