Atarim on MariaDB Vector: Moving RAG Storage from Qdrant to MariaDB

Atarim has replaced Qdrant with MariaDB as the vector store for its internal RAG system. The team describes the change as close to a direct replacement, made for easier integration, data sovereignty and fewer vendors to manage. Vectors and their metadata are now stored in a single relational database on AWS, and filtered searches in production return in about 10 ms.
Atarim is an AI web agency that uses AI-powered workflows to handle ongoing site care for its clients’ websites. Its RAG system gives Atarim’s AI agents the context of each client: when an agent works on a task, it retrieves the relevant passages from documents uploaded to that client’s workspace, so the work follows that client’s standards and preferences.
In this article, we explain why Atarim made this change, how the system is designed and how the migration worked in practice. We also describe a second way Atarim uses MariaDB: database tools for its clients’ WordPress sites. A follow-up article will look at performance with larger data volumes, based on synthetic benchmark tests against Qdrant.
Architecture: one database for vectors and related data
Atarim’s RAG service runs on AWS. Its storage layer is MariaDB 11.8 on Amazon RDS. The team chose version 11.8 because it is available on RDS. It is also the first long-term support (LTS) release that includes MariaDB Vector.
The database stores the embeddings and their metadata together, in one table per document collection:
- Embeddings for the document collection, stored in a
VECTORcolumn and searched through a vector index. - File metadata about each source document, stored next to each embedding in a JSON payload.
Before the migration, the embeddings were stored in Qdrant, a dedicated vector database, and the other data was stored separately. Now everything is in one system. Vector search and metadata filtering run as SQL queries over a single connection, with one approach to backups and access control.
Atarim creates its embeddings with OpenAI’s text-embedding-3-small model at 1,536 dimensions. The RAG service is a Laravel 12 application that connects through Laravel’s native MariaDB database driver. The MariaDB instance serves only the RAG system; no other services use it.
Implementation: vectors as a normal column
In MariaDB Vector, an embedding is simply a column type, and a nearest-neighbor search is an ORDER BY ... LIMIT query. The schema below is an example. It shows the general pattern, not Atarim’s actual tables.
CREATE TABLE documents (
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
file_name VARCHAR(255) NOT NULL,
source_url VARCHAR(1024),
updated_at DATETIME NOT NULL
);
CREATE TABLE doc_chunks (
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
document_id BIGINT UNSIGNED NOT NULL,
chunk_index INT NOT NULL,
content TEXT NOT NULL,
embedding VECTOR(1536) NOT NULL,
KEY (document_id),
VECTOR INDEX (embedding) M=8 DISTANCE=cosine
);
The VECTOR INDEX is based on HNSW. MariaDB calls its implementation MHNSW. The M parameter controls the balance between index size and build time on one side and search accuracy (recall) on the other. The DISTANCE parameter sets the distance metric the index uses. The indexed column must be NOT NULL.
Embeddings are inserted as text arrays and converted to vectors:
INSERT INTO doc_chunks (document_id, chunk_index, content, embedding)
VALUES (42, 0, 'First chunk of text...', VEC_FromText('[0.0132, -0.0841, ...]'));
Retrieval is a single query. Because the metadata is in the same database, joining the documents table needs no extra work:
SELECT d.file_name,
c.content,
VEC_DISTANCE_COSINE(c.embedding, VEC_FromText(?)) AS distance
FROM doc_chunks c
JOIN documents d ON d.id = c.document_id
ORDER BY distance
LIMIT 5;
The optimizer uses the vector index when the query sorts by a distance function that matches the index metric and includes a LIMIT. The mhnsw_ef_search session variable controls how widely the search explores the index, so you can trade some speed for better recall. In production, Atarim found it better to parse the query vector once, for example in a derived table, instead of calling VEC_FromText inside the distance expression. The migration section below explains why.
Atarim’s production schema is simpler than this example. Each collection is a single table, and the metadata stays in a JSON payload:
CREATE TABLE collection_global (
id VARCHAR(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL PRIMARY KEY,
embedding VECTOR(1536) NOT NULL,
payload JSON NOT NULL,
VECTOR INDEX embedding_ann (embedding) M=16 DISTANCE=cosine
) ENGINE=InnoDB;
ALTER TABLE collection_global
ADD COLUMN pf_vector_file_id BIGINT AS (
IF(JSON_TYPE(JSON_EXTRACT(payload, '$.vector_file_id')) = 'INTEGER',
CAST(JSON_VALUE(payload, '$.vector_file_id') AS SIGNED), NULL)
) VIRTUAL,
ADD INDEX pf_vector_file_id_idx (pf_vector_file_id);
The payload holds four fields: vector_file_id, unit, kind and source. Each integer field that searches filter on gets an indexed virtual column, so limiting a search to the files of one client workspace is a B-tree lookup. Those filtered searches then score each remaining row exactly, with IGNORE INDEX (embedding_ann). The vector index uses 1,536 dimensions, M=16 and cosine distance.
Documents are split into chunks by a variant of context-atlas, a library written by Fox Islam of Atarim. It uses a decision model to cut each document into semantically complete chunks, based on the type of document.
Migrating from Qdrant
Atarim’s team described the migration as close to a direct replacement. They changed the vector store, and the rest of the RAG pipeline stayed the same. A migration like this usually involves three steps:
- Create the tables for vectors and metadata, with a vector index on the embedding column.
- Move the data. Export each Qdrant point’s payload, copy or regenerate its embedding, and insert both as a row.
- Replace the retrieval call. Replace the Qdrant search request with the SQL query shown above, so that the same top-k chunks are passed to the prompt-building step.
The main design change is in step 2. Qdrant stores metadata as a flexible JSON payload attached to each point. In MariaDB, this metadata becomes typed columns in related tables, or a JSON column where the structure really needs to stay open. As a result, it can be queried and joined like any other business data.
Atarim did not copy the vectors from Qdrant. The team regenerated the embeddings and kept the payload as a JSON column, with indexed virtual columns for the fields that searches filter on. Two issues came up during the switch:
- Filtered searches returned too few results. Every search Atarim runs is limited to the files of one client workspace. With the HNSW index, MariaDB finds the nearest neighbors first and applies the filter afterwards, so many of the neighbors it found were filtered out. Atarim switched these queries to exact scoring with
IGNORE INDEX. Because the filter leaves only a few hundred rows to score, recall improved and latency went down. - The query vector was parsed once per row. With
VEC_FromTextinside the distance expression, MariaDB converted the query vector again for every row it scored. Parsing it once in a derived table cut the query time considerably.
Looking back, the team would design filtered and unfiltered queries as separate paths from the start. Being able to narrow the candidates with SQL before scoring them turned out to be MariaDB’s main advantage over a dedicated vector database for Atarim’s workload.
Performance after the migration
In production, Atarim stores 9,708 vectors from 412 files on a db.t4g.micro RDS instance. A search filtered to the files of one workspace returns the top 20 results in 10.3 ms (median, warm cache). An unfiltered search over the whole collection takes 27.1 ms, but Atarim does not run unfiltered searches.
To compare the two stores directly, the team ran MariaDB 11.8 and Qdrant 1.14 side by side on one machine with default settings, real embeddings and MariaDB memory matched to the production instance. At current data sizes, MariaDB was 1.6 to 3.3 times faster than Qdrant on filtered searches, with the same recall:
| Vectors | Filtered median, Qdrant | Filtered median, MariaDB | Filtered recall (both) |
|---|---|---|---|
| 5,000 | 8.8 ms | 2.7 ms | 0.996 |
| 10,000 | 4.1 ms | 2.4 ms | 0.998 |
| 22,000 | 3.9 ms | 2.4 ms | 0.998 |
MariaDB also handled more filtered queries under load. At 22,000 vectors with 16 concurrent clients, it served 1,292 queries per second against 880 for Qdrant. On unfiltered searches, which use the HNSW index, Qdrant was faster and returned better results: its recall was 1.00, against 0.89 to 0.94 for MariaDB.
The current data set is small, so these results do not show how either store behaves as the data grows. A second article will cover that, with synthetic benchmarks that scale the data to 50 times its current size.
Beyond RAG: MariaDB tools for WordPress sites
Atarim also uses MariaDB in a second, customer-facing way. WordPress runs on MySQL or MariaDB, and Atarim offers its WordPress clients three types of database tools:
- Health checks for the site database.
- LLM-based querying, so users can ask questions about their site data in natural language.
- Actions, which allow an LLM to perform operations on the database through defined tools.
A logical next step is semantic indexing of WordPress content. This would mean storing embeddings for posts, pages or other tables in the site’s own database, so that the vector search described above also works on customer data. This raises two questions:
- Storage impact. Embeddings add considerable size to each row.
- Customer control. Customers should be able to decide which tables are vectorized. The team has tested selective table vectorization and partitioning as ways to limit the extra storage.
Atarim measured this on a synthetic but representative WordPress database with about 1,200 posts, pages and products (95 MB). Vectorizing every text column, including revisions, comments and long postmeta values, added 552 MB, almost six times the size of the site. Two thirds of those chunks came from revisions. Limiting vectorization to published posts, pages and products added 120 MB.
Using fewer dimensions saves more space but lowers accuracy. At 512 dimensions, the added storage fell to 46 MB, but recall dropped to about 80% of what Atarim’s current 1,536-dimension setup achieves. The full results:
| What is vectorized | Chunks | Added storage | Compared with site size |
|---|---|---|---|
| Everything with text, including revisions, comments and long postmeta | 44,543 | 552 MB | 5.9× |
| Published posts, pages and products | 8,406 | 120 MB | 1.28× |
| Published content plus approved comments | 11,091 | 148 MB | 1.57× |
| Published content, 768 dimensions | 8,406 | 68 MB | 0.72× |
| Published content, 512 dimensions | 8,406 | 46 MB | 0.49× |
| Published content, 256 dimensions | 8,406 | 32 MB | 0.34× |
| Published content, no vector index (exact search) | 8,406 | 76 MB | 0.81× |
| Published content, partitioned by type, no index | 8,406 | 90 MB | 0.96× |
Atarim and MariaDB will present the system in a live clean up on December 3. Register here.
Leave a Reply