Details
-
New Feature
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
-
None
Description
For the first iteration of Vector search, we will implement HNSW algorithm.
The implementation will only support Euclidean distance initially.
Basic plan:
Graph construction will be done according to HNSW paper.
Storage wise, we'll store the graph as part of a subtable (MDEV-33404).
The table's definition will be something along these lines:
CREATE TABLE i ( |
level int unsigned not null, |
src varbinary(255) not null, |
dst varbinary(255) not null, |
index (level,src), |
index (level,dst)); |
For each link in the graph, there will be a corresponding entry in the table.
- src and dst will store handler::position, a quick link to the actual vector blob in the main table.
The index (level,src) will allow for quick jumping between nodes.
To go deeper in search, one just needs to decrement the level and search using the same "src" value.
If src is found on level n, then it is also found on level n - 1 and so on. Level 0 is the base level with all the nodes.
Performance considerations:
- Storing the vector in the subtable might be required. Looking up the blob value in the base table might be too costly.
Attachments
Issue Links
- blocks
-
MDEV-33411 OPTIMIZE for graph indexes
-
- Open
-
-
MDEV-33414 benchmark vector indexes
-
- Closed
-
-
MDEV-33415 graph index search: heuristical edge choice
-
- Closed
-
-
MDEV-33416 graph index: use smaller floating point numbers
-
- Closed
-
-
MDEV-33418 graph index insert: stronger selection of neighbors
-
- Closed
-
-
MDEV-33419 graph index insert: consider more neighbors
-
- Open
-
- is blocked by
-
MDEV-33404 Engine-independent indexes: subtable method
-
- Closed
-
-
MDEV-36317 vector search with Cosine Distance, the recall rate of the returned results is very low
-
- Open
-
-
MDEV-36338 vector search with Cosine Distance is slow
-
- Closed
-
- is part of
-
MDEV-34939 vector search in 11.7
-
- Closed
-
- relates to
-
MDEV-32887 vector search
-
- Stalled
-
Got it, thanks! So I built bb-11.6-MDEV-32887-vector, and the build process seemed to go fine. In the log I can see at startup:
2024-07-03 15:45:53 0 [Note] Starting MariaDB 11.6.0-MariaDB source revision 77a016686ec2a2617dd6489a756b1f9f11a78d9f as process 27924
Which seems to be the latest commit on that branch as far as I can tell, so it looks like I've gotten the proper source. But when I run "ALTER TABLE data ADD COLUMN embedding VECTOR(100);", I get "SQL Error (4161): Unknown data type: 'VECTOR'". Is there something else I need to enable to test?