Turning MariaDB Into a Vector Database: MariaDB Vector Explained

Опубликовано: 19 Август 2024
на канале: Database Dive
42
2

This vector database video will act as a MariaDB tutorial explaining how MariaDB Vector works.
According to the CEO of MariaDB Foundation, Kaj Arnö, MariaDB Foundation has been approached numerous times in regards to what's their take on vector databases.
As a result, the MariaDB Server team has started developing the MariaDB Vector appliance and this MariaDB tutorial will show you what's under the hood.

This MySQL tutorial will tell you that in MariaDB Server, vector search looks like so and introduces new, specific syntax to MariaDB as well as a new SQL index type to facilitate quick searching for vector database embeddings:

CREATE TABLE `products` (
`title` varchar(128),
`description` varchar(2000),
VECTOR INDEX (`embedding`)
ENGINE=InnoDB);

Here, a database vector is defined as a SQL index type rather than a column.
This SQL tutorial for beginners will tell you that in MariaDB Server, a vector isn't a MariaDB storage engine either - at present, the MariaDB vector is a feature in a preview mode.

This SQL tutorial will tell you that to work with vector embeddings in MariaDB, you would first need to insert data.
To do that, you would insert values as per the column specification as well as a numeric representation of a vector using the VEC_FromText function as shown in the SQL query below:
INSERT INTO `products` (`title`, `description`, `embedding`) VALUES ('Ferrari', 'Ferrari is a nice car', VEC_FromText('[0.3, 0.5, 0.2, 0.1]'));

To facilitate the search through vector embeddings, you would have to employ queries using the VEC_DISTANCE and VEC_FromText functions. A SQL query like so will help:
SELECT p.name, p.description FROM products AS p ORDER BY VEC_DISTANCE(p.embedding, VEC_FromText('[0.3, 0,5, 0.1, 0.3]') LIMIT 10;

These functions would ask MariaDB to make use of its optimizer to use the vector SQL index that is specifically tuned for this task.
If your SELECT query has an ORDER BY VEC_DISTANCE clause and a LIMIT clause, MariaDB Server will make use of the VECTOR INDEX definition.
As always, you can verify whether other database indexes are used using the EXPLAIN clause.

This MariaDB tutorial will tell you that MariaDB Vector preview implements a modified version of the Hierarchical Navigable Small Worlds (HNSW) algorithm.
Given that this algorithm is used in many vector databases, its use to facilitate support for MariaDB vector capability isn't at all surprising.

This MySQL tutorial will further tell you that MariaDB developers recommend using MariaDB vector search to implement powerful search functionalities to find similar images, documents, or multimedia content, find related rows in a table without labelling them, or even to build personalized product recommendations based on user behavior.

What do you think about MariaDB vector search? Share your thoughts in the comment section below, subscribe to this channel to see more content revolving around databases, MySQL, MariaDB, and other sql interview questions and answers, and until next time.

Sources:
MariaDB Foundation:
https://mariadb.org/projects/mariadb-...
   • MariaDB Vector: A storage engine for ...  

Music:
Insane - Mehul Choudhary:   / mehulchoudhary  
Creative Commons — Attribution 3.0 Unported — CC BY 3.0
Free Download / Stream: https://bit.ly/3ylmhTm
Music promoted by Audio Library https://bit.ly/3yBgokX

#database #mariadb #mysql #development #developer


Смотрите видео Turning MariaDB Into a Vector Database: MariaDB Vector Explained онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Database Dive 19 Август 2024, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 4 раз и оно понравилось людям.