[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-mariadb-mariadb-vector":3,"mdc--sg4g9-key":31,"related-repo-mariadb-mariadb-vector":2518,"related-org-mariadb-mariadb-vector":2606},{"slug":4,"name":4,"fn":5,"description":6,"org":7,"tags":11,"stars":20,"repoUrl":21,"updatedAt":22,"license":23,"forks":24,"topics":25,"repo":26,"sourceUrl":29,"mdContent":30},"mariadb-vector","build semantic search with MariaDB vectors","Best practices for using vectors and AI with MariaDB. Use when writing SQL involving VECTOR columns, building RAG or semantic search with MariaDB, choosing embedding models, designing vector indexes, or integrating MariaDB with AI frameworks like LangChain, LlamaIndex, or Spring AI. Also use when the user mentions MariaDB and any of: vectors, embeddings, similarity search, nearest neighbor, AI, RAG, or LLM. IMPORTANT — MariaDB has native built-in vector support since version 11.7; it is NOT a plugin or extension (unlike pgvector for PostgreSQL). Do not recommend installing any extension.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},"mariadb","MariaDB","https:\u002F\u002Fpexgzepcugksgbtrxkhf.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Forg-logos\u002Fmariadb.png",[12,14,17],{"name":9,"slug":8,"type":13},"tag",{"name":15,"slug":16,"type":13},"Database","database",{"name":18,"slug":19,"type":13},"Migration","migration",9,"https:\u002F\u002Fgithub.com\u002FMariaDB\u002Fskills","2026-07-13T06:14:01.939479",null,2,[],{"repoUrl":21,"stars":20,"forks":24,"topics":27,"description":28},[],"MariaDB skills for Claude Code and AI agents - because it is not MySQL","https:\u002F\u002Fgithub.com\u002FMariaDB\u002Fskills\u002Ftree\u002FHEAD\u002Fmariadb-vector","---\nname: mariadb-vector\ndescription: \"Best practices for using vectors and AI with MariaDB. Use when writing SQL involving VECTOR columns, building RAG or semantic search with MariaDB, choosing embedding models, designing vector indexes, or integrating MariaDB with AI frameworks like LangChain, LlamaIndex, or Spring AI. Also use when the user mentions MariaDB and any of: vectors, embeddings, similarity search, nearest neighbor, AI, RAG, or LLM. IMPORTANT — MariaDB has native built-in vector support since version 11.7; it is NOT a plugin or extension (unlike pgvector for PostgreSQL). Do not recommend installing any extension.\"\n---\n\n# MariaDB Vector & AI Best Practices\n\n*Last updated: 2026-06-04*\n\n## Critical: MariaDB Vector Is Built-In\n\nMariaDB has **native, built-in** vector support since version 11.7. The `VECTOR` type, `VECTOR INDEX`, and all `VEC_*` functions ship with the server — nothing to install, enable, or load.\n\nThis is different from MySQL (which has no native vector support) and PostgreSQL (which requires the pgvector extension). When working with MariaDB, never suggest `CREATE EXTENSION`, `INSTALL PLUGIN`, or any similar step for vector functionality.\n\n> **Requires:** MariaDB Community Server **11.7+** (GA Feb 2025) for native vectors; **11.8 LTS** (GA May 2025) recommended. Enterprise: 11.4+ (tech preview) \u002F 11.8+ (full support). Next LTS: **12.3** — check [MariaDB releases](https:\u002F\u002Fmariadb.org\u002Fmariadb\u002Fall-releases\u002F) for GA status before treating it as the default.\n>\n> **Default context:** Do not suggest vector features below **11.7**. For other MariaDB behavior, assume **11.8 LTS** unless the user states another version. Features marked **12.x** may be suggested when relevant; always state the minimum version.\n\n### What LLMs Get Wrong\n\n| What you might see | What's correct |\n|---|---|\n| \"Install the `pgvector` extension\" or \"run `INSTALL PLUGIN vector`\" | Nothing to install — MariaDB Vector is built-in since 11.7 |\n| `ORDER BY VEC_DISTANCE_EUCLIDEAN(...)` without `LIMIT` | Always add `LIMIT` — the vector index is only used when both `ORDER BY VEC_DISTANCE_*()` and `LIMIT` are present |\n| `embedding VECTOR(768)` (nullable) on an indexed column | Indexed vector columns must be `NOT NULL` |\n| Using `VEC_DISTANCE()` on a non-indexed column | `VEC_DISTANCE()` throws error 4206 (\"index is not found\"); use `VEC_DISTANCE_EUCLIDEAN()` or `VEC_DISTANCE_COSINE()` for unindexed columns |\n\n## Core Syntax\n\n### Create a Table With a Vector Column\n\n```sql\nCREATE TABLE documents (\n    id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,\n    content TEXT NOT NULL,\n    embedding VECTOR(768) NOT NULL,\n    VECTOR INDEX (embedding)\n) ENGINE=InnoDB;\n```\n\nUse `ENGINE=InnoDB` (the default). MyISAM\u002FAria had a bug with FK + vector indexes (MDEV-37022, fixed in 11.8.3); InnoDB is the safe default regardless of version.\n\nThe number in `VECTOR(n)` must match the dimensionality of your embedding model's output (e.g., 768 for many sentence-transformer models, 1536 for OpenAI text-embedding-3-small, 3072 for text-embedding-3-large).\n\n### Vector Index Options\n\n```sql\nVECTOR INDEX (embedding) M=6 DISTANCE=euclidean   -- default\nVECTOR INDEX (embedding) M=8 DISTANCE=cosine\n```\n\n- **DISTANCE**: `euclidean` (default) or `cosine`. Pick the one your embedding model recommends. Both are equally fast in MariaDB thanks to SIMD optimizations. **Always declare `DISTANCE=` explicitly**. default to euclidian and a cosine query against a euclidean index silently full-scans.\n- **M**: Controls the HNSW graph connectivity (range 3–200). Higher values improve recall but cost more memory and slower inserts. Default is fine for most workloads; increase to ~16–32 for very large datasets where recall matters more than insert speed.\n\n### Insert Vectors\n\nVectors are stored as packed 32-bit IEEE 754 floats little-endian encoded. Bind raw bytes from application code — **5× faster than `VEC_FromText()`**. Stored bytes are identical.\n\n```python\nimport numpy as np\ncur.execute(\n    \"INSERT INTO documents (content, embedding) VALUES (?, ?)\",\n    (content, np.asarray(embedding, dtype=np.float32).tobytes()),\n)\n```\n\nUse `VEC_FromText()` only for hand-written SQL \u002F CLI:\n\n```sql\nINSERT INTO documents (content, embedding) VALUES ('your text here', VEC_FromText('[0.12, -0.34, 0.56, ...]'));\n```\n\n### Query: Find Nearest Neighbors\n\n```sql\nSELECT id, content\nFROM documents\nORDER BY VEC_DISTANCE_EUCLIDEAN(embedding, VEC_FromText('[0.12, -0.34, 0.56, ...]'))\nLIMIT 10;\n```\n\n**The LIMIT clause is essential.** The MariaDB optimizer only uses the VECTOR INDEX when the query has both `ORDER BY VEC_DISTANCE_...()` and `LIMIT`. Without `LIMIT`, it falls back to a full table scan.\n\n### Distance Functions\n\n| Function | Use When |\n|---|---|\n| `VEC_DISTANCE_EUCLIDEAN(a, b)` | Index was built with `DISTANCE=euclidean` (default) |\n| `VEC_DISTANCE_COSINE(a, b)` | Index was built with `DISTANCE=cosine` |\n| `VEC_DISTANCE(a, b)` | Generic — uses the distance function matching the column's index; throws error 4206 if no index is found |\n\nUse `VEC_DISTANCE_EUCLIDEAN()` or `VEC_DISTANCE_COSINE()` for unindexed columns (they fall back to a full scan). Use `VEC_DISTANCE()` only on indexed columns as a convenience shorthand.\n\n### Utility Functions\n\n| Function | Purpose |\n|---|---|\n| `VEC_FromText('[0.1, 0.2, ...]')` | Convert JSON float array to VECTOR binary |\n| `VEC_ToText(vector_col)` | Convert VECTOR binary to readable JSON array |\n\n**Always wrap a VECTOR column in `VEC_ToText()` when you want to read it.** A `VECTOR` is stored as packed binary floats, so `SELECT embedding FROM documents` returns the raw bytes — they render as unreadable gibberish in a CLI or client. Use `SELECT VEC_ToText(embedding) FROM documents` to get the `[0.12, -0.34, ...]` array instead.\n\n## MariaDB Vector Gotchas\n\n- **Indexed VECTOR columns must be NOT NULL.** The VECTOR INDEX requires it. A VECTOR column without an index can be nullable, but in practice you almost always want the index, so always include `NOT NULL`.\n- **No dot product distance.** MariaDB intentionally omits it. Dot product is not a proper distance metric (a vector's closest match is not necessarily itself). MariaDB's SIMD-optimized euclidean and cosine are already as fast as dot product would be, so use euclidean or cosine for normalized vectors.\n- **Match the distance function to the index.** `VEC_DISTANCE_EUCLIDEAN()` on a `DISTANCE=cosine` index (or vice versa) will not use the index.\n- **One VECTOR INDEX per table.** Currently MariaDB supports a single vector index per table.\n- **Adding a vector index to an existing table:**\n  ```sql\n  ALTER TABLE my_table ADD COLUMN embedding VECTOR(768) NOT NULL;\n  -- populate the column first, then:\n  ALTER TABLE my_table ADD VECTOR INDEX (embedding);\n  ```\n- **Index precision.** MariaDB uses `int16` for index storage (15 bits of precision), which is better than the 10 bits of float16 used by some other implementations. This means higher recall at the same speed.\n- **`ORDER BY` must be the literal `VEC_DISTANCE_*(col, ?)` call (or its alias) with `ASC` direction.** Wrapping the distance in an expression (e.g. `ORDER BY (1.0 - VEC_DISTANCE_COSINE(...)) DESC LIMIT N` to sort by similarity score) breaks the optimizer's HNSW pattern match and falls back to a full scan. Compute the score in an outer SELECT instead:\n  ```sql\n  SELECT t.id, 1.0 - t.distance AS score FROM (\n      SELECT id, VEC_DISTANCE_COSINE(embedding, ?) AS distance\n      FROM docs ORDER BY distance ASC LIMIT 10\n  ) AS t ORDER BY score DESC;\n  ```\n- **`WHERE VEC_DISTANCE(...) \u003C threshold` is a full scan.** The vector index only engages with `ORDER BY VEC_DISTANCE(...) LIMIT N`. For threshold queries, wrap the indexed top-K in a subquery and filter outside\n  ```sql\n  SELECT * FROM (\n      SELECT content, VEC_DISTANCE_COSINE(embedding, ?) AS distance\n      FROM chunks ORDER BY distance LIMIT 100\n  ) AS t WHERE t.distance \u003C 0.5;\n  ```\n  `LIMIT K` is a hard cap; pick K generously if many rows may match.\n\n## RAG (Retrieval-Augmented Generation) Pattern\n\nThe most common AI use case with MariaDB Vector. The flow:\n\n1. **Chunk** your documents into passages (typically 200–1000 tokens).\n2. **Embed** each chunk using your model (OpenAI, Sentence Transformers, Cohere, etc.).\n3. **Store** chunks with their embeddings in MariaDB.\n4. At query time, **embed** the user's question with the same model.\n5. **Retrieve** the nearest chunks (bind `:user_embedding` as float32 bytes):\n   ```sql\n   SELECT content\n   FROM chunks\n   ORDER BY VEC_DISTANCE(embedding, :user_embedding)\n   LIMIT 5;\n   ```\n6. **Feed** retrieved chunks as context to your LLM for the final answer.\n\n**See also:** To combine full-text (keyword) and vector retrieval, see [Hybrid search with Reciprocal Rank Fusion (RRF)](https:\u002F\u002Fmariadb.com\u002Fdocs\u002Fserver\u002Freference\u002Fsql-structure\u002Fvectors\u002Foptimizing-hybrid-search-query-with-reciprocal-rank-fusion-rrf) — useful when queries mix exact terms with semantic paraphrase.\n\n### RAG Table Design\n\n```sql\nCREATE TABLE chunks (\n    chunk_id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,\n    doc_id BIGINT UNSIGNED NOT NULL,\n    chunk_index INT UNSIGNED NOT NULL,\n    content TEXT NOT NULL,\n    embedding VECTOR(768) NOT NULL,\n    VECTOR INDEX (embedding) DISTANCE=cosine,\n    INDEX (doc_id)\n) ENGINE=InnoDB;\n```\n\nKeep `doc_id` indexed so you can join back to the source document or filter by document. The `chunk_index` preserves ordering within a document.\n\n### Minimal End-to-End Python Example\n\n```python\nimport mariadb\nimport numpy as np\nfrom openai import OpenAI\n\nclient = OpenAI()\n\ndef embed(text):\n    vec = client.embeddings.create(input=text, model=\"text-embedding-3-small\").data[0].embedding\n    return np.asarray(vec, dtype=np.float32).tobytes()\n\n# Create database and table if they don't exist\nconn = mariadb.connect(host=\"127.0.0.1\", port=3306, user=\"root\", password=\"\")\ncur = conn.cursor()\ncur.execute(\"CREATE DATABASE IF NOT EXISTS ragdb\")\ncur.execute(\"USE ragdb\")\ncur.execute(\"\"\"\n    CREATE TABLE IF NOT EXISTS chunks (\n        chunk_id  BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,\n        content   TEXT NOT NULL,\n        embedding VECTOR(1536) NOT NULL,\n        VECTOR INDEX (embedding) DISTANCE=cosine\n    ) ENGINE=InnoDB\n\"\"\")\nconn.commit()\n\n# Store a document chunk\ncur.execute(\n    \"INSERT INTO chunks (content, embedding) VALUES (?, ?)\",\n    (\"MariaDB Vector stores embeddings natively\", embed(\"MariaDB Vector stores embeddings natively\"))\n)\nconn.commit()\n\n# Retrieve top-5 nearest chunks for a user question\nquestion_vec = embed(\"How does MariaDB store vectors?\")\ncur.execute(\"\"\"\n    SELECT content, VEC_DISTANCE_COSINE(embedding, ?) AS distance\n    FROM chunks\n    ORDER BY distance\n    LIMIT 5\n\"\"\", (question_vec,))\ncontext = \"\\n\".join(row[0] for row in cur.fetchall())\n# Pass `context` to your LLM as the retrieved context for the answer\n```\n\nThe `mariadb` connector (`pip install mariadb`) is the official Python driver. On big-endian hosts, use `dtype=\"\u003Cf4\"` to force little-endian.\n\n## Framework Integrations\n\nMariaDB Vector is integrated with major AI frameworks. Use these instead of writing raw SQL when building applications:\n\n| Framework | Language | Link |\n|---|---|---|\n| LangChain | Python | `pip install langchain-mariadb` |\n| LangChain.js | Node.js | Built-in MariaDB vector store |\n| LangChain4j | Java | Built-in MariaDB embedding store |\n| LlamaIndex | Python | Built-in MariaDB vector store |\n| Spring AI | Java | Built-in MariaDB vector store |\n| MariaDB MCP Server | Python | [github.com\u002Fmariadb\u002Fmcp](https:\u002F\u002Fgithub.com\u002FMariaDB\u002Fmcp) |\n\nWhen using frameworks, you typically configure a connection string and the framework handles `VEC_FromText`, `VEC_DISTANCE`, and `LIMIT` for you.\n\n## Choosing an Embedding Model\n\nThe embedding model determines vector quality. Some practical guidance:\n\n- **Start with a sentence-transformer model** (e.g., `all-MiniLM-L6-v2`, 384 dimensions) for prototyping. Free, fast, runs locally.\n- **OpenAI `text-embedding-3-small`** (1536 dimensions) is a solid production choice if you're already using OpenAI. *(Dimensions correct as of May 2026 — verify against current model docs.)*\n- **Match dimensions to your VECTOR(n) column.** A mismatch will cause insert errors.\n- **Never mix embeddings from different models** in the same column. Distances between vectors from different models are meaningless.\n- **Cosine distance is the standard** for most text embedding models. Check your model's documentation.\n\n## Performance Notes\n\n- MariaDB Vector uses **SIMD hardware optimizations** (AVX2, AVX512 on Intel; NEON on ARM; VSX on IBM Power10). No configuration needed — it detects and uses the best available instruction set.\n- **Faster vector distance via extrapolation** (12.1+, MDEV-36205) — vector search is 30–50% faster on the same data and recall, with no schema or index changes required. The optimization applies automatically to vectors that can be gradually truncated to trade recall for speed (e.g. Matryoshka-style embeddings from OpenAI).\n- **Multi-connection scalability** is a strength. Benchmark results show MariaDB Vector scales well with concurrent queries, outperforming some dedicated vector databases in multi-threaded scenarios.\n- For large datasets (millions of vectors), tune the **M parameter** upward and ensure sufficient memory for the index.\n- **Bulk inserts**: load data first, then create the vector index. This is significantly faster than inserting into an already-indexed table.\n- **Bind embeddings as binary** (`float32.tobytes()`), not `VEC_FromText()`. ~5× faster, ~5× smaller wire payload, byte-identical storage.\n\n### Tuning: mhnsw System Variables\n\nThese session\u002Fglobal variables let you tune search quality and memory at runtime without rebuilding the index:\n\n- **`mhnsw_ef_search`** (default: `20`) — minimum candidates considered for `ORDER BY … LIMIT N` queries. Raise this if recall is low at small `LIMIT` values; lower it to trade recall for speed.\n- **`mhnsw_max_cache_size`** (default: `16777216` \u002F 16 MB, global only) — per-index in-memory cache cap. For best performance the entire vector graph should fit in this cache; size it to match your index.\n- **`mhnsw_default_m`** (default: `6`) and **`mhnsw_default_distance`** (default: `euclidean`) set the implicit values used when `M` or `DISTANCE` are omitted from a `VECTOR INDEX` declaration.\n\n## Sources\n\n- [Vector Overview](https:\u002F\u002Fmariadb.com\u002Fdocs\u002Fserver\u002Freference\u002Fsql-structure\u002Fvectors\u002Fvector-overview) — official docs entry point\n- [CREATE TABLE with Vectors](https:\u002F\u002Fmariadb.com\u002Fdocs\u002Fserver\u002Freference\u002Fsql-structure\u002Fvectors\u002Fcreate-table-with-vectors) — index options, NOT NULL requirement, limitations\n- [VEC_FromText](https:\u002F\u002Fmariadb.com\u002Fdocs\u002Fserver\u002Freference\u002Fsql-functions\u002Fvector-functions\u002Fvec_fromtext) — converts JSON float array to binary VECTOR\n- [VEC_ToText](https:\u002F\u002Fmariadb.com\u002Fdocs\u002Fserver\u002Freference\u002Fsql-functions\u002Fvector-functions\u002Fvec_totext) — converts binary VECTOR to JSON float array\n- [VEC_DISTANCE](https:\u002F\u002Fmariadb.com\u002Fdocs\u002Fserver\u002Freference\u002Fsql-functions\u002Fvector-functions\u002Fvector-functions-vec_distance) — generic distance, requires index\n- [VEC_DISTANCE_EUCLIDEAN](https:\u002F\u002Fmariadb.com\u002Fdocs\u002Fserver\u002Freference\u002Fsql-functions\u002Fvector-functions\u002Fvec_distance_euclidean)\n- [VEC_DISTANCE_COSINE](https:\u002F\u002Fmariadb.com\u002Fdocs\u002Fserver\u002Freference\u002Fsql-functions\u002Fvector-functions\u002Fvec_distance_cosine)\n- [RAG with MariaDB Vector tutorial](https:\u002F\u002Fmariadb.org\u002Frag-with-mariadb-vector\u002F) — end-to-end Python + OpenAI example\n- [Hybrid search with RRF](https:\u002F\u002Fmariadb.com\u002Fdocs\u002Fserver\u002Freference\u002Fsql-structure\u002Fvectors\u002Foptimizing-hybrid-search-query-with-reciprocal-rank-fusion-rrf) — merge full-text and vector ranked lists\n- [MariaDB Vector project page](https:\u002F\u002Fmariadb.org\u002Fprojects\u002Fmariadb-vector\u002F)\n- [MariaDB MCP Server](https:\u002F\u002Fgithub.com\u002FMariaDB\u002Fmcp)\n\n*For topics not covered here, see the official MariaDB documentation at [mariadb.com\u002Fdocs](https:\u002F\u002Fmariadb.com\u002Fdocs).*\n",{"data":32,"body":33},{"name":4,"description":6},{"type":34,"children":35},"root",[36,45,55,62,100,121,197,204,375,381,387,453,466,479,485,508,564,570,588,637,648,662,668,707,738,744,830,854,860,915,964,970,1241,1247,1252,1365,1384,1390,1468,1489,1495,1862,1890,1896,1901,2040,2067,2073,2078,2150,2156,2238,2244,2249,2368,2374,2496,2512],{"type":37,"tag":38,"props":39,"children":41},"element","h1",{"id":40},"mariadb-vector-ai-best-practices",[42],{"type":43,"value":44},"text","MariaDB Vector & AI Best Practices",{"type":37,"tag":46,"props":47,"children":48},"p",{},[49],{"type":37,"tag":50,"props":51,"children":52},"em",{},[53],{"type":43,"value":54},"Last updated: 2026-06-04",{"type":37,"tag":56,"props":57,"children":59},"h2",{"id":58},"critical-mariadb-vector-is-built-in",[60],{"type":43,"value":61},"Critical: MariaDB Vector Is Built-In",{"type":37,"tag":46,"props":63,"children":64},{},[65,67,73,75,82,84,90,92,98],{"type":43,"value":66},"MariaDB has ",{"type":37,"tag":68,"props":69,"children":70},"strong",{},[71],{"type":43,"value":72},"native, built-in",{"type":43,"value":74}," vector support since version 11.7. The ",{"type":37,"tag":76,"props":77,"children":79},"code",{"className":78},[],[80],{"type":43,"value":81},"VECTOR",{"type":43,"value":83}," type, ",{"type":37,"tag":76,"props":85,"children":87},{"className":86},[],[88],{"type":43,"value":89},"VECTOR INDEX",{"type":43,"value":91},", and all ",{"type":37,"tag":76,"props":93,"children":95},{"className":94},[],[96],{"type":43,"value":97},"VEC_*",{"type":43,"value":99}," functions ship with the server — nothing to install, enable, or load.",{"type":37,"tag":46,"props":101,"children":102},{},[103,105,111,113,119],{"type":43,"value":104},"This is different from MySQL (which has no native vector support) and PostgreSQL (which requires the pgvector extension). When working with MariaDB, never suggest ",{"type":37,"tag":76,"props":106,"children":108},{"className":107},[],[109],{"type":43,"value":110},"CREATE EXTENSION",{"type":43,"value":112},", ",{"type":37,"tag":76,"props":114,"children":116},{"className":115},[],[117],{"type":43,"value":118},"INSTALL PLUGIN",{"type":43,"value":120},", or any similar step for vector functionality.",{"type":37,"tag":122,"props":123,"children":124},"blockquote",{},[125,167],{"type":37,"tag":46,"props":126,"children":127},{},[128,133,135,140,142,147,149,154,156,165],{"type":37,"tag":68,"props":129,"children":130},{},[131],{"type":43,"value":132},"Requires:",{"type":43,"value":134}," MariaDB Community Server ",{"type":37,"tag":68,"props":136,"children":137},{},[138],{"type":43,"value":139},"11.7+",{"type":43,"value":141}," (GA Feb 2025) for native vectors; ",{"type":37,"tag":68,"props":143,"children":144},{},[145],{"type":43,"value":146},"11.8 LTS",{"type":43,"value":148}," (GA May 2025) recommended. Enterprise: 11.4+ (tech preview) \u002F 11.8+ (full support). Next LTS: ",{"type":37,"tag":68,"props":150,"children":151},{},[152],{"type":43,"value":153},"12.3",{"type":43,"value":155}," — check ",{"type":37,"tag":157,"props":158,"children":162},"a",{"href":159,"rel":160},"https:\u002F\u002Fmariadb.org\u002Fmariadb\u002Fall-releases\u002F",[161],"nofollow",[163],{"type":43,"value":164},"MariaDB releases",{"type":43,"value":166}," for GA status before treating it as the default.",{"type":37,"tag":46,"props":168,"children":169},{},[170,175,177,182,184,188,190,195],{"type":37,"tag":68,"props":171,"children":172},{},[173],{"type":43,"value":174},"Default context:",{"type":43,"value":176}," Do not suggest vector features below ",{"type":37,"tag":68,"props":178,"children":179},{},[180],{"type":43,"value":181},"11.7",{"type":43,"value":183},". For other MariaDB behavior, assume ",{"type":37,"tag":68,"props":185,"children":186},{},[187],{"type":43,"value":146},{"type":43,"value":189}," unless the user states another version. Features marked ",{"type":37,"tag":68,"props":191,"children":192},{},[193],{"type":43,"value":194},"12.x",{"type":43,"value":196}," may be suggested when relevant; always state the minimum version.",{"type":37,"tag":198,"props":199,"children":201},"h3",{"id":200},"what-llms-get-wrong",[202],{"type":43,"value":203},"What LLMs Get Wrong",{"type":37,"tag":205,"props":206,"children":207},"table",{},[208,227],{"type":37,"tag":209,"props":210,"children":211},"thead",{},[212],{"type":37,"tag":213,"props":214,"children":215},"tr",{},[216,222],{"type":37,"tag":217,"props":218,"children":219},"th",{},[220],{"type":43,"value":221},"What you might see",{"type":37,"tag":217,"props":223,"children":224},{},[225],{"type":43,"value":226},"What's correct",{"type":37,"tag":228,"props":229,"children":230},"tbody",{},[231,261,308,333],{"type":37,"tag":213,"props":232,"children":233},{},[234,256],{"type":37,"tag":235,"props":236,"children":237},"td",{},[238,240,246,248,254],{"type":43,"value":239},"\"Install the ",{"type":37,"tag":76,"props":241,"children":243},{"className":242},[],[244],{"type":43,"value":245},"pgvector",{"type":43,"value":247}," extension\" or \"run ",{"type":37,"tag":76,"props":249,"children":251},{"className":250},[],[252],{"type":43,"value":253},"INSTALL PLUGIN vector",{"type":43,"value":255},"\"",{"type":37,"tag":235,"props":257,"children":258},{},[259],{"type":43,"value":260},"Nothing to install — MariaDB Vector is built-in since 11.7",{"type":37,"tag":213,"props":262,"children":263},{},[264,281],{"type":37,"tag":235,"props":265,"children":266},{},[267,273,275],{"type":37,"tag":76,"props":268,"children":270},{"className":269},[],[271],{"type":43,"value":272},"ORDER BY VEC_DISTANCE_EUCLIDEAN(...)",{"type":43,"value":274}," without ",{"type":37,"tag":76,"props":276,"children":278},{"className":277},[],[279],{"type":43,"value":280},"LIMIT",{"type":37,"tag":235,"props":282,"children":283},{},[284,286,291,293,299,301,306],{"type":43,"value":285},"Always add ",{"type":37,"tag":76,"props":287,"children":289},{"className":288},[],[290],{"type":43,"value":280},{"type":43,"value":292}," — the vector index is only used when both ",{"type":37,"tag":76,"props":294,"children":296},{"className":295},[],[297],{"type":43,"value":298},"ORDER BY VEC_DISTANCE_*()",{"type":43,"value":300}," and ",{"type":37,"tag":76,"props":302,"children":304},{"className":303},[],[305],{"type":43,"value":280},{"type":43,"value":307}," are present",{"type":37,"tag":213,"props":309,"children":310},{},[311,322],{"type":37,"tag":235,"props":312,"children":313},{},[314,320],{"type":37,"tag":76,"props":315,"children":317},{"className":316},[],[318],{"type":43,"value":319},"embedding VECTOR(768)",{"type":43,"value":321}," (nullable) on an indexed column",{"type":37,"tag":235,"props":323,"children":324},{},[325,327],{"type":43,"value":326},"Indexed vector columns must be ",{"type":37,"tag":76,"props":328,"children":330},{"className":329},[],[331],{"type":43,"value":332},"NOT NULL",{"type":37,"tag":213,"props":334,"children":335},{},[336,349],{"type":37,"tag":235,"props":337,"children":338},{},[339,341,347],{"type":43,"value":340},"Using ",{"type":37,"tag":76,"props":342,"children":344},{"className":343},[],[345],{"type":43,"value":346},"VEC_DISTANCE()",{"type":43,"value":348}," on a non-indexed column",{"type":37,"tag":235,"props":350,"children":351},{},[352,357,359,365,367,373],{"type":37,"tag":76,"props":353,"children":355},{"className":354},[],[356],{"type":43,"value":346},{"type":43,"value":358}," throws error 4206 (\"index is not found\"); use ",{"type":37,"tag":76,"props":360,"children":362},{"className":361},[],[363],{"type":43,"value":364},"VEC_DISTANCE_EUCLIDEAN()",{"type":43,"value":366}," or ",{"type":37,"tag":76,"props":368,"children":370},{"className":369},[],[371],{"type":43,"value":372},"VEC_DISTANCE_COSINE()",{"type":43,"value":374}," for unindexed columns",{"type":37,"tag":56,"props":376,"children":378},{"id":377},"core-syntax",[379],{"type":43,"value":380},"Core Syntax",{"type":37,"tag":198,"props":382,"children":384},{"id":383},"create-a-table-with-a-vector-column",[385],{"type":43,"value":386},"Create a Table With a Vector Column",{"type":37,"tag":388,"props":389,"children":394},"pre",{"className":390,"code":391,"language":392,"meta":393,"style":393},"language-sql shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","CREATE TABLE documents (\n    id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,\n    content TEXT NOT NULL,\n    embedding VECTOR(768) NOT NULL,\n    VECTOR INDEX (embedding)\n) ENGINE=InnoDB;\n","sql","",[395],{"type":37,"tag":76,"props":396,"children":397},{"__ignoreMap":393},[398,409,417,426,435,444],{"type":37,"tag":399,"props":400,"children":403},"span",{"class":401,"line":402},"line",1,[404],{"type":37,"tag":399,"props":405,"children":406},{},[407],{"type":43,"value":408},"CREATE TABLE documents (\n",{"type":37,"tag":399,"props":410,"children":411},{"class":401,"line":24},[412],{"type":37,"tag":399,"props":413,"children":414},{},[415],{"type":43,"value":416},"    id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,\n",{"type":37,"tag":399,"props":418,"children":420},{"class":401,"line":419},3,[421],{"type":37,"tag":399,"props":422,"children":423},{},[424],{"type":43,"value":425},"    content TEXT NOT NULL,\n",{"type":37,"tag":399,"props":427,"children":429},{"class":401,"line":428},4,[430],{"type":37,"tag":399,"props":431,"children":432},{},[433],{"type":43,"value":434},"    embedding VECTOR(768) NOT NULL,\n",{"type":37,"tag":399,"props":436,"children":438},{"class":401,"line":437},5,[439],{"type":37,"tag":399,"props":440,"children":441},{},[442],{"type":43,"value":443},"    VECTOR INDEX (embedding)\n",{"type":37,"tag":399,"props":445,"children":447},{"class":401,"line":446},6,[448],{"type":37,"tag":399,"props":449,"children":450},{},[451],{"type":43,"value":452},") ENGINE=InnoDB;\n",{"type":37,"tag":46,"props":454,"children":455},{},[456,458,464],{"type":43,"value":457},"Use ",{"type":37,"tag":76,"props":459,"children":461},{"className":460},[],[462],{"type":43,"value":463},"ENGINE=InnoDB",{"type":43,"value":465}," (the default). MyISAM\u002FAria had a bug with FK + vector indexes (MDEV-37022, fixed in 11.8.3); InnoDB is the safe default regardless of version.",{"type":37,"tag":46,"props":467,"children":468},{},[469,471,477],{"type":43,"value":470},"The number in ",{"type":37,"tag":76,"props":472,"children":474},{"className":473},[],[475],{"type":43,"value":476},"VECTOR(n)",{"type":43,"value":478}," must match the dimensionality of your embedding model's output (e.g., 768 for many sentence-transformer models, 1536 for OpenAI text-embedding-3-small, 3072 for text-embedding-3-large).",{"type":37,"tag":198,"props":480,"children":482},{"id":481},"vector-index-options",[483],{"type":43,"value":484},"Vector Index Options",{"type":37,"tag":388,"props":486,"children":488},{"className":390,"code":487,"language":392,"meta":393,"style":393},"VECTOR INDEX (embedding) M=6 DISTANCE=euclidean   -- default\nVECTOR INDEX (embedding) M=8 DISTANCE=cosine\n",[489],{"type":37,"tag":76,"props":490,"children":491},{"__ignoreMap":393},[492,500],{"type":37,"tag":399,"props":493,"children":494},{"class":401,"line":402},[495],{"type":37,"tag":399,"props":496,"children":497},{},[498],{"type":43,"value":499},"VECTOR INDEX (embedding) M=6 DISTANCE=euclidean   -- default\n",{"type":37,"tag":399,"props":501,"children":502},{"class":401,"line":24},[503],{"type":37,"tag":399,"props":504,"children":505},{},[506],{"type":43,"value":507},"VECTOR INDEX (embedding) M=8 DISTANCE=cosine\n",{"type":37,"tag":509,"props":510,"children":511},"ul",{},[512,554],{"type":37,"tag":513,"props":514,"children":515},"li",{},[516,521,523,529,531,537,539,552],{"type":37,"tag":68,"props":517,"children":518},{},[519],{"type":43,"value":520},"DISTANCE",{"type":43,"value":522},": ",{"type":37,"tag":76,"props":524,"children":526},{"className":525},[],[527],{"type":43,"value":528},"euclidean",{"type":43,"value":530}," (default) or ",{"type":37,"tag":76,"props":532,"children":534},{"className":533},[],[535],{"type":43,"value":536},"cosine",{"type":43,"value":538},". Pick the one your embedding model recommends. Both are equally fast in MariaDB thanks to SIMD optimizations. ",{"type":37,"tag":68,"props":540,"children":541},{},[542,544,550],{"type":43,"value":543},"Always declare ",{"type":37,"tag":76,"props":545,"children":547},{"className":546},[],[548],{"type":43,"value":549},"DISTANCE=",{"type":43,"value":551}," explicitly",{"type":43,"value":553},". default to euclidian and a cosine query against a euclidean index silently full-scans.",{"type":37,"tag":513,"props":555,"children":556},{},[557,562],{"type":37,"tag":68,"props":558,"children":559},{},[560],{"type":43,"value":561},"M",{"type":43,"value":563},": Controls the HNSW graph connectivity (range 3–200). Higher values improve recall but cost more memory and slower inserts. Default is fine for most workloads; increase to ~16–32 for very large datasets where recall matters more than insert speed.",{"type":37,"tag":198,"props":565,"children":567},{"id":566},"insert-vectors",[568],{"type":43,"value":569},"Insert Vectors",{"type":37,"tag":46,"props":571,"children":572},{},[573,575,586],{"type":43,"value":574},"Vectors are stored as packed 32-bit IEEE 754 floats little-endian encoded. Bind raw bytes from application code — ",{"type":37,"tag":68,"props":576,"children":577},{},[578,580],{"type":43,"value":579},"5× faster than ",{"type":37,"tag":76,"props":581,"children":583},{"className":582},[],[584],{"type":43,"value":585},"VEC_FromText()",{"type":43,"value":587},". Stored bytes are identical.",{"type":37,"tag":388,"props":589,"children":593},{"className":590,"code":591,"language":592,"meta":393,"style":393},"language-python shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import numpy as np\ncur.execute(\n    \"INSERT INTO documents (content, embedding) VALUES (?, ?)\",\n    (content, np.asarray(embedding, dtype=np.float32).tobytes()),\n)\n","python",[594],{"type":37,"tag":76,"props":595,"children":596},{"__ignoreMap":393},[597,605,613,621,629],{"type":37,"tag":399,"props":598,"children":599},{"class":401,"line":402},[600],{"type":37,"tag":399,"props":601,"children":602},{},[603],{"type":43,"value":604},"import numpy as np\n",{"type":37,"tag":399,"props":606,"children":607},{"class":401,"line":24},[608],{"type":37,"tag":399,"props":609,"children":610},{},[611],{"type":43,"value":612},"cur.execute(\n",{"type":37,"tag":399,"props":614,"children":615},{"class":401,"line":419},[616],{"type":37,"tag":399,"props":617,"children":618},{},[619],{"type":43,"value":620},"    \"INSERT INTO documents (content, embedding) VALUES (?, ?)\",\n",{"type":37,"tag":399,"props":622,"children":623},{"class":401,"line":428},[624],{"type":37,"tag":399,"props":625,"children":626},{},[627],{"type":43,"value":628},"    (content, np.asarray(embedding, dtype=np.float32).tobytes()),\n",{"type":37,"tag":399,"props":630,"children":631},{"class":401,"line":437},[632],{"type":37,"tag":399,"props":633,"children":634},{},[635],{"type":43,"value":636},")\n",{"type":37,"tag":46,"props":638,"children":639},{},[640,641,646],{"type":43,"value":457},{"type":37,"tag":76,"props":642,"children":644},{"className":643},[],[645],{"type":43,"value":585},{"type":43,"value":647}," only for hand-written SQL \u002F CLI:",{"type":37,"tag":388,"props":649,"children":651},{"className":390,"code":650,"language":392,"meta":393,"style":393},"INSERT INTO documents (content, embedding) VALUES ('your text here', VEC_FromText('[0.12, -0.34, 0.56, ...]'));\n",[652],{"type":37,"tag":76,"props":653,"children":654},{"__ignoreMap":393},[655],{"type":37,"tag":399,"props":656,"children":657},{"class":401,"line":402},[658],{"type":37,"tag":399,"props":659,"children":660},{},[661],{"type":43,"value":650},{"type":37,"tag":198,"props":663,"children":665},{"id":664},"query-find-nearest-neighbors",[666],{"type":43,"value":667},"Query: Find Nearest Neighbors",{"type":37,"tag":388,"props":669,"children":671},{"className":390,"code":670,"language":392,"meta":393,"style":393},"SELECT id, content\nFROM documents\nORDER BY VEC_DISTANCE_EUCLIDEAN(embedding, VEC_FromText('[0.12, -0.34, 0.56, ...]'))\nLIMIT 10;\n",[672],{"type":37,"tag":76,"props":673,"children":674},{"__ignoreMap":393},[675,683,691,699],{"type":37,"tag":399,"props":676,"children":677},{"class":401,"line":402},[678],{"type":37,"tag":399,"props":679,"children":680},{},[681],{"type":43,"value":682},"SELECT id, content\n",{"type":37,"tag":399,"props":684,"children":685},{"class":401,"line":24},[686],{"type":37,"tag":399,"props":687,"children":688},{},[689],{"type":43,"value":690},"FROM documents\n",{"type":37,"tag":399,"props":692,"children":693},{"class":401,"line":419},[694],{"type":37,"tag":399,"props":695,"children":696},{},[697],{"type":43,"value":698},"ORDER BY VEC_DISTANCE_EUCLIDEAN(embedding, VEC_FromText('[0.12, -0.34, 0.56, ...]'))\n",{"type":37,"tag":399,"props":700,"children":701},{"class":401,"line":428},[702],{"type":37,"tag":399,"props":703,"children":704},{},[705],{"type":43,"value":706},"LIMIT 10;\n",{"type":37,"tag":46,"props":708,"children":709},{},[710,715,717,723,724,729,731,736],{"type":37,"tag":68,"props":711,"children":712},{},[713],{"type":43,"value":714},"The LIMIT clause is essential.",{"type":43,"value":716}," The MariaDB optimizer only uses the VECTOR INDEX when the query has both ",{"type":37,"tag":76,"props":718,"children":720},{"className":719},[],[721],{"type":43,"value":722},"ORDER BY VEC_DISTANCE_...()",{"type":43,"value":300},{"type":37,"tag":76,"props":725,"children":727},{"className":726},[],[728],{"type":43,"value":280},{"type":43,"value":730},". Without ",{"type":37,"tag":76,"props":732,"children":734},{"className":733},[],[735],{"type":43,"value":280},{"type":43,"value":737},", it falls back to a full table scan.",{"type":37,"tag":198,"props":739,"children":741},{"id":740},"distance-functions",[742],{"type":43,"value":743},"Distance Functions",{"type":37,"tag":205,"props":745,"children":746},{},[747,763],{"type":37,"tag":209,"props":748,"children":749},{},[750],{"type":37,"tag":213,"props":751,"children":752},{},[753,758],{"type":37,"tag":217,"props":754,"children":755},{},[756],{"type":43,"value":757},"Function",{"type":37,"tag":217,"props":759,"children":760},{},[761],{"type":43,"value":762},"Use When",{"type":37,"tag":228,"props":764,"children":765},{},[766,791,813],{"type":37,"tag":213,"props":767,"children":768},{},[769,778],{"type":37,"tag":235,"props":770,"children":771},{},[772],{"type":37,"tag":76,"props":773,"children":775},{"className":774},[],[776],{"type":43,"value":777},"VEC_DISTANCE_EUCLIDEAN(a, b)",{"type":37,"tag":235,"props":779,"children":780},{},[781,783,789],{"type":43,"value":782},"Index was built with ",{"type":37,"tag":76,"props":784,"children":786},{"className":785},[],[787],{"type":43,"value":788},"DISTANCE=euclidean",{"type":43,"value":790}," (default)",{"type":37,"tag":213,"props":792,"children":793},{},[794,803],{"type":37,"tag":235,"props":795,"children":796},{},[797],{"type":37,"tag":76,"props":798,"children":800},{"className":799},[],[801],{"type":43,"value":802},"VEC_DISTANCE_COSINE(a, b)",{"type":37,"tag":235,"props":804,"children":805},{},[806,807],{"type":43,"value":782},{"type":37,"tag":76,"props":808,"children":810},{"className":809},[],[811],{"type":43,"value":812},"DISTANCE=cosine",{"type":37,"tag":213,"props":814,"children":815},{},[816,825],{"type":37,"tag":235,"props":817,"children":818},{},[819],{"type":37,"tag":76,"props":820,"children":822},{"className":821},[],[823],{"type":43,"value":824},"VEC_DISTANCE(a, b)",{"type":37,"tag":235,"props":826,"children":827},{},[828],{"type":43,"value":829},"Generic — uses the distance function matching the column's index; throws error 4206 if no index is found",{"type":37,"tag":46,"props":831,"children":832},{},[833,834,839,840,845,847,852],{"type":43,"value":457},{"type":37,"tag":76,"props":835,"children":837},{"className":836},[],[838],{"type":43,"value":364},{"type":43,"value":366},{"type":37,"tag":76,"props":841,"children":843},{"className":842},[],[844],{"type":43,"value":372},{"type":43,"value":846}," for unindexed columns (they fall back to a full scan). Use ",{"type":37,"tag":76,"props":848,"children":850},{"className":849},[],[851],{"type":43,"value":346},{"type":43,"value":853}," only on indexed columns as a convenience shorthand.",{"type":37,"tag":198,"props":855,"children":857},{"id":856},"utility-functions",[858],{"type":43,"value":859},"Utility Functions",{"type":37,"tag":205,"props":861,"children":862},{},[863,878],{"type":37,"tag":209,"props":864,"children":865},{},[866],{"type":37,"tag":213,"props":867,"children":868},{},[869,873],{"type":37,"tag":217,"props":870,"children":871},{},[872],{"type":43,"value":757},{"type":37,"tag":217,"props":874,"children":875},{},[876],{"type":43,"value":877},"Purpose",{"type":37,"tag":228,"props":879,"children":880},{},[881,898],{"type":37,"tag":213,"props":882,"children":883},{},[884,893],{"type":37,"tag":235,"props":885,"children":886},{},[887],{"type":37,"tag":76,"props":888,"children":890},{"className":889},[],[891],{"type":43,"value":892},"VEC_FromText('[0.1, 0.2, ...]')",{"type":37,"tag":235,"props":894,"children":895},{},[896],{"type":43,"value":897},"Convert JSON float array to VECTOR binary",{"type":37,"tag":213,"props":899,"children":900},{},[901,910],{"type":37,"tag":235,"props":902,"children":903},{},[904],{"type":37,"tag":76,"props":905,"children":907},{"className":906},[],[908],{"type":43,"value":909},"VEC_ToText(vector_col)",{"type":37,"tag":235,"props":911,"children":912},{},[913],{"type":43,"value":914},"Convert VECTOR binary to readable JSON array",{"type":37,"tag":46,"props":916,"children":917},{},[918,931,933,938,940,946,948,954,956,962],{"type":37,"tag":68,"props":919,"children":920},{},[921,923,929],{"type":43,"value":922},"Always wrap a VECTOR column in ",{"type":37,"tag":76,"props":924,"children":926},{"className":925},[],[927],{"type":43,"value":928},"VEC_ToText()",{"type":43,"value":930}," when you want to read it.",{"type":43,"value":932}," A ",{"type":37,"tag":76,"props":934,"children":936},{"className":935},[],[937],{"type":43,"value":81},{"type":43,"value":939}," is stored as packed binary floats, so ",{"type":37,"tag":76,"props":941,"children":943},{"className":942},[],[944],{"type":43,"value":945},"SELECT embedding FROM documents",{"type":43,"value":947}," returns the raw bytes — they render as unreadable gibberish in a CLI or client. Use ",{"type":37,"tag":76,"props":949,"children":951},{"className":950},[],[952],{"type":43,"value":953},"SELECT VEC_ToText(embedding) FROM documents",{"type":43,"value":955}," to get the ",{"type":37,"tag":76,"props":957,"children":959},{"className":958},[],[960],{"type":43,"value":961},"[0.12, -0.34, ...]",{"type":43,"value":963}," array instead.",{"type":37,"tag":56,"props":965,"children":967},{"id":966},"mariadb-vector-gotchas",[968],{"type":43,"value":969},"MariaDB Vector Gotchas",{"type":37,"tag":509,"props":971,"children":972},{},[973,990,1000,1024,1034,1073,1091,1170],{"type":37,"tag":513,"props":974,"children":975},{},[976,981,983,988],{"type":37,"tag":68,"props":977,"children":978},{},[979],{"type":43,"value":980},"Indexed VECTOR columns must be NOT NULL.",{"type":43,"value":982}," The VECTOR INDEX requires it. A VECTOR column without an index can be nullable, but in practice you almost always want the index, so always include ",{"type":37,"tag":76,"props":984,"children":986},{"className":985},[],[987],{"type":43,"value":332},{"type":43,"value":989},".",{"type":37,"tag":513,"props":991,"children":992},{},[993,998],{"type":37,"tag":68,"props":994,"children":995},{},[996],{"type":43,"value":997},"No dot product distance.",{"type":43,"value":999}," MariaDB intentionally omits it. Dot product is not a proper distance metric (a vector's closest match is not necessarily itself). MariaDB's SIMD-optimized euclidean and cosine are already as fast as dot product would be, so use euclidean or cosine for normalized vectors.",{"type":37,"tag":513,"props":1001,"children":1002},{},[1003,1008,1010,1015,1017,1022],{"type":37,"tag":68,"props":1004,"children":1005},{},[1006],{"type":43,"value":1007},"Match the distance function to the index.",{"type":43,"value":1009}," ",{"type":37,"tag":76,"props":1011,"children":1013},{"className":1012},[],[1014],{"type":43,"value":364},{"type":43,"value":1016}," on a ",{"type":37,"tag":76,"props":1018,"children":1020},{"className":1019},[],[1021],{"type":43,"value":812},{"type":43,"value":1023}," index (or vice versa) will not use the index.",{"type":37,"tag":513,"props":1025,"children":1026},{},[1027,1032],{"type":37,"tag":68,"props":1028,"children":1029},{},[1030],{"type":43,"value":1031},"One VECTOR INDEX per table.",{"type":43,"value":1033}," Currently MariaDB supports a single vector index per table.",{"type":37,"tag":513,"props":1035,"children":1036},{},[1037,1042],{"type":37,"tag":68,"props":1038,"children":1039},{},[1040],{"type":43,"value":1041},"Adding a vector index to an existing table:",{"type":37,"tag":388,"props":1043,"children":1045},{"className":390,"code":1044,"language":392,"meta":393,"style":393},"ALTER TABLE my_table ADD COLUMN embedding VECTOR(768) NOT NULL;\n-- populate the column first, then:\nALTER TABLE my_table ADD VECTOR INDEX (embedding);\n",[1046],{"type":37,"tag":76,"props":1047,"children":1048},{"__ignoreMap":393},[1049,1057,1065],{"type":37,"tag":399,"props":1050,"children":1051},{"class":401,"line":402},[1052],{"type":37,"tag":399,"props":1053,"children":1054},{},[1055],{"type":43,"value":1056},"ALTER TABLE my_table ADD COLUMN embedding VECTOR(768) NOT NULL;\n",{"type":37,"tag":399,"props":1058,"children":1059},{"class":401,"line":24},[1060],{"type":37,"tag":399,"props":1061,"children":1062},{},[1063],{"type":43,"value":1064},"-- populate the column first, then:\n",{"type":37,"tag":399,"props":1066,"children":1067},{"class":401,"line":419},[1068],{"type":37,"tag":399,"props":1069,"children":1070},{},[1071],{"type":43,"value":1072},"ALTER TABLE my_table ADD VECTOR INDEX (embedding);\n",{"type":37,"tag":513,"props":1074,"children":1075},{},[1076,1081,1083,1089],{"type":37,"tag":68,"props":1077,"children":1078},{},[1079],{"type":43,"value":1080},"Index precision.",{"type":43,"value":1082}," MariaDB uses ",{"type":37,"tag":76,"props":1084,"children":1086},{"className":1085},[],[1087],{"type":43,"value":1088},"int16",{"type":43,"value":1090}," for index storage (15 bits of precision), which is better than the 10 bits of float16 used by some other implementations. This means higher recall at the same speed.",{"type":37,"tag":513,"props":1092,"children":1093},{},[1094,1121,1123,1129,1131],{"type":37,"tag":68,"props":1095,"children":1096},{},[1097,1103,1105,1111,1113,1119],{"type":37,"tag":76,"props":1098,"children":1100},{"className":1099},[],[1101],{"type":43,"value":1102},"ORDER BY",{"type":43,"value":1104}," must be the literal ",{"type":37,"tag":76,"props":1106,"children":1108},{"className":1107},[],[1109],{"type":43,"value":1110},"VEC_DISTANCE_*(col, ?)",{"type":43,"value":1112}," call (or its alias) with ",{"type":37,"tag":76,"props":1114,"children":1116},{"className":1115},[],[1117],{"type":43,"value":1118},"ASC",{"type":43,"value":1120}," direction.",{"type":43,"value":1122}," Wrapping the distance in an expression (e.g. ",{"type":37,"tag":76,"props":1124,"children":1126},{"className":1125},[],[1127],{"type":43,"value":1128},"ORDER BY (1.0 - VEC_DISTANCE_COSINE(...)) DESC LIMIT N",{"type":43,"value":1130}," to sort by similarity score) breaks the optimizer's HNSW pattern match and falls back to a full scan. Compute the score in an outer SELECT instead:\n",{"type":37,"tag":388,"props":1132,"children":1134},{"className":390,"code":1133,"language":392,"meta":393,"style":393},"SELECT t.id, 1.0 - t.distance AS score FROM (\n    SELECT id, VEC_DISTANCE_COSINE(embedding, ?) AS distance\n    FROM docs ORDER BY distance ASC LIMIT 10\n) AS t ORDER BY score DESC;\n",[1135],{"type":37,"tag":76,"props":1136,"children":1137},{"__ignoreMap":393},[1138,1146,1154,1162],{"type":37,"tag":399,"props":1139,"children":1140},{"class":401,"line":402},[1141],{"type":37,"tag":399,"props":1142,"children":1143},{},[1144],{"type":43,"value":1145},"SELECT t.id, 1.0 - t.distance AS score FROM (\n",{"type":37,"tag":399,"props":1147,"children":1148},{"class":401,"line":24},[1149],{"type":37,"tag":399,"props":1150,"children":1151},{},[1152],{"type":43,"value":1153},"    SELECT id, VEC_DISTANCE_COSINE(embedding, ?) AS distance\n",{"type":37,"tag":399,"props":1155,"children":1156},{"class":401,"line":419},[1157],{"type":37,"tag":399,"props":1158,"children":1159},{},[1160],{"type":43,"value":1161},"    FROM docs ORDER BY distance ASC LIMIT 10\n",{"type":37,"tag":399,"props":1163,"children":1164},{"class":401,"line":428},[1165],{"type":37,"tag":399,"props":1166,"children":1167},{},[1168],{"type":43,"value":1169},") AS t ORDER BY score DESC;\n",{"type":37,"tag":513,"props":1171,"children":1172},{},[1173,1184,1186,1192,1194,1233,1239],{"type":37,"tag":68,"props":1174,"children":1175},{},[1176,1182],{"type":37,"tag":76,"props":1177,"children":1179},{"className":1178},[],[1180],{"type":43,"value":1181},"WHERE VEC_DISTANCE(...) \u003C threshold",{"type":43,"value":1183}," is a full scan.",{"type":43,"value":1185}," The vector index only engages with ",{"type":37,"tag":76,"props":1187,"children":1189},{"className":1188},[],[1190],{"type":43,"value":1191},"ORDER BY VEC_DISTANCE(...) LIMIT N",{"type":43,"value":1193},". For threshold queries, wrap the indexed top-K in a subquery and filter outside\n",{"type":37,"tag":388,"props":1195,"children":1197},{"className":390,"code":1196,"language":392,"meta":393,"style":393},"SELECT * FROM (\n    SELECT content, VEC_DISTANCE_COSINE(embedding, ?) AS distance\n    FROM chunks ORDER BY distance LIMIT 100\n) AS t WHERE t.distance \u003C 0.5;\n",[1198],{"type":37,"tag":76,"props":1199,"children":1200},{"__ignoreMap":393},[1201,1209,1217,1225],{"type":37,"tag":399,"props":1202,"children":1203},{"class":401,"line":402},[1204],{"type":37,"tag":399,"props":1205,"children":1206},{},[1207],{"type":43,"value":1208},"SELECT * FROM (\n",{"type":37,"tag":399,"props":1210,"children":1211},{"class":401,"line":24},[1212],{"type":37,"tag":399,"props":1213,"children":1214},{},[1215],{"type":43,"value":1216},"    SELECT content, VEC_DISTANCE_COSINE(embedding, ?) AS distance\n",{"type":37,"tag":399,"props":1218,"children":1219},{"class":401,"line":419},[1220],{"type":37,"tag":399,"props":1221,"children":1222},{},[1223],{"type":43,"value":1224},"    FROM chunks ORDER BY distance LIMIT 100\n",{"type":37,"tag":399,"props":1226,"children":1227},{"class":401,"line":428},[1228],{"type":37,"tag":399,"props":1229,"children":1230},{},[1231],{"type":43,"value":1232},") AS t WHERE t.distance \u003C 0.5;\n",{"type":37,"tag":76,"props":1234,"children":1236},{"className":1235},[],[1237],{"type":43,"value":1238},"LIMIT K",{"type":43,"value":1240}," is a hard cap; pick K generously if many rows may match.",{"type":37,"tag":56,"props":1242,"children":1244},{"id":1243},"rag-retrieval-augmented-generation-pattern",[1245],{"type":43,"value":1246},"RAG (Retrieval-Augmented Generation) Pattern",{"type":37,"tag":46,"props":1248,"children":1249},{},[1250],{"type":43,"value":1251},"The most common AI use case with MariaDB Vector. The flow:",{"type":37,"tag":1253,"props":1254,"children":1255},"ol",{},[1256,1266,1276,1286,1298,1355],{"type":37,"tag":513,"props":1257,"children":1258},{},[1259,1264],{"type":37,"tag":68,"props":1260,"children":1261},{},[1262],{"type":43,"value":1263},"Chunk",{"type":43,"value":1265}," your documents into passages (typically 200–1000 tokens).",{"type":37,"tag":513,"props":1267,"children":1268},{},[1269,1274],{"type":37,"tag":68,"props":1270,"children":1271},{},[1272],{"type":43,"value":1273},"Embed",{"type":43,"value":1275}," each chunk using your model (OpenAI, Sentence Transformers, Cohere, etc.).",{"type":37,"tag":513,"props":1277,"children":1278},{},[1279,1284],{"type":37,"tag":68,"props":1280,"children":1281},{},[1282],{"type":43,"value":1283},"Store",{"type":43,"value":1285}," chunks with their embeddings in MariaDB.",{"type":37,"tag":513,"props":1287,"children":1288},{},[1289,1291,1296],{"type":43,"value":1290},"At query time, ",{"type":37,"tag":68,"props":1292,"children":1293},{},[1294],{"type":43,"value":1295},"embed",{"type":43,"value":1297}," the user's question with the same model.",{"type":37,"tag":513,"props":1299,"children":1300},{},[1301,1306,1308,1314,1316],{"type":37,"tag":68,"props":1302,"children":1303},{},[1304],{"type":43,"value":1305},"Retrieve",{"type":43,"value":1307}," the nearest chunks (bind ",{"type":37,"tag":76,"props":1309,"children":1311},{"className":1310},[],[1312],{"type":43,"value":1313},":user_embedding",{"type":43,"value":1315}," as float32 bytes):\n",{"type":37,"tag":388,"props":1317,"children":1319},{"className":390,"code":1318,"language":392,"meta":393,"style":393},"SELECT content\nFROM chunks\nORDER BY VEC_DISTANCE(embedding, :user_embedding)\nLIMIT 5;\n",[1320],{"type":37,"tag":76,"props":1321,"children":1322},{"__ignoreMap":393},[1323,1331,1339,1347],{"type":37,"tag":399,"props":1324,"children":1325},{"class":401,"line":402},[1326],{"type":37,"tag":399,"props":1327,"children":1328},{},[1329],{"type":43,"value":1330},"SELECT content\n",{"type":37,"tag":399,"props":1332,"children":1333},{"class":401,"line":24},[1334],{"type":37,"tag":399,"props":1335,"children":1336},{},[1337],{"type":43,"value":1338},"FROM chunks\n",{"type":37,"tag":399,"props":1340,"children":1341},{"class":401,"line":419},[1342],{"type":37,"tag":399,"props":1343,"children":1344},{},[1345],{"type":43,"value":1346},"ORDER BY VEC_DISTANCE(embedding, :user_embedding)\n",{"type":37,"tag":399,"props":1348,"children":1349},{"class":401,"line":428},[1350],{"type":37,"tag":399,"props":1351,"children":1352},{},[1353],{"type":43,"value":1354},"LIMIT 5;\n",{"type":37,"tag":513,"props":1356,"children":1357},{},[1358,1363],{"type":37,"tag":68,"props":1359,"children":1360},{},[1361],{"type":43,"value":1362},"Feed",{"type":43,"value":1364}," retrieved chunks as context to your LLM for the final answer.",{"type":37,"tag":46,"props":1366,"children":1367},{},[1368,1373,1375,1382],{"type":37,"tag":68,"props":1369,"children":1370},{},[1371],{"type":43,"value":1372},"See also:",{"type":43,"value":1374}," To combine full-text (keyword) and vector retrieval, see ",{"type":37,"tag":157,"props":1376,"children":1379},{"href":1377,"rel":1378},"https:\u002F\u002Fmariadb.com\u002Fdocs\u002Fserver\u002Freference\u002Fsql-structure\u002Fvectors\u002Foptimizing-hybrid-search-query-with-reciprocal-rank-fusion-rrf",[161],[1380],{"type":43,"value":1381},"Hybrid search with Reciprocal Rank Fusion (RRF)",{"type":43,"value":1383}," — useful when queries mix exact terms with semantic paraphrase.",{"type":37,"tag":198,"props":1385,"children":1387},{"id":1386},"rag-table-design",[1388],{"type":43,"value":1389},"RAG Table Design",{"type":37,"tag":388,"props":1391,"children":1393},{"className":390,"code":1392,"language":392,"meta":393,"style":393},"CREATE TABLE chunks (\n    chunk_id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,\n    doc_id BIGINT UNSIGNED NOT NULL,\n    chunk_index INT UNSIGNED NOT NULL,\n    content TEXT NOT NULL,\n    embedding VECTOR(768) NOT NULL,\n    VECTOR INDEX (embedding) DISTANCE=cosine,\n    INDEX (doc_id)\n) ENGINE=InnoDB;\n",[1394],{"type":37,"tag":76,"props":1395,"children":1396},{"__ignoreMap":393},[1397,1405,1413,1421,1429,1436,1443,1452,1461],{"type":37,"tag":399,"props":1398,"children":1399},{"class":401,"line":402},[1400],{"type":37,"tag":399,"props":1401,"children":1402},{},[1403],{"type":43,"value":1404},"CREATE TABLE chunks (\n",{"type":37,"tag":399,"props":1406,"children":1407},{"class":401,"line":24},[1408],{"type":37,"tag":399,"props":1409,"children":1410},{},[1411],{"type":43,"value":1412},"    chunk_id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,\n",{"type":37,"tag":399,"props":1414,"children":1415},{"class":401,"line":419},[1416],{"type":37,"tag":399,"props":1417,"children":1418},{},[1419],{"type":43,"value":1420},"    doc_id BIGINT UNSIGNED NOT NULL,\n",{"type":37,"tag":399,"props":1422,"children":1423},{"class":401,"line":428},[1424],{"type":37,"tag":399,"props":1425,"children":1426},{},[1427],{"type":43,"value":1428},"    chunk_index INT UNSIGNED NOT NULL,\n",{"type":37,"tag":399,"props":1430,"children":1431},{"class":401,"line":437},[1432],{"type":37,"tag":399,"props":1433,"children":1434},{},[1435],{"type":43,"value":425},{"type":37,"tag":399,"props":1437,"children":1438},{"class":401,"line":446},[1439],{"type":37,"tag":399,"props":1440,"children":1441},{},[1442],{"type":43,"value":434},{"type":37,"tag":399,"props":1444,"children":1446},{"class":401,"line":1445},7,[1447],{"type":37,"tag":399,"props":1448,"children":1449},{},[1450],{"type":43,"value":1451},"    VECTOR INDEX (embedding) DISTANCE=cosine,\n",{"type":37,"tag":399,"props":1453,"children":1455},{"class":401,"line":1454},8,[1456],{"type":37,"tag":399,"props":1457,"children":1458},{},[1459],{"type":43,"value":1460},"    INDEX (doc_id)\n",{"type":37,"tag":399,"props":1462,"children":1463},{"class":401,"line":20},[1464],{"type":37,"tag":399,"props":1465,"children":1466},{},[1467],{"type":43,"value":452},{"type":37,"tag":46,"props":1469,"children":1470},{},[1471,1473,1479,1481,1487],{"type":43,"value":1472},"Keep ",{"type":37,"tag":76,"props":1474,"children":1476},{"className":1475},[],[1477],{"type":43,"value":1478},"doc_id",{"type":43,"value":1480}," indexed so you can join back to the source document or filter by document. The ",{"type":37,"tag":76,"props":1482,"children":1484},{"className":1483},[],[1485],{"type":43,"value":1486},"chunk_index",{"type":43,"value":1488}," preserves ordering within a document.",{"type":37,"tag":198,"props":1490,"children":1492},{"id":1491},"minimal-end-to-end-python-example",[1493],{"type":43,"value":1494},"Minimal End-to-End Python Example",{"type":37,"tag":388,"props":1496,"children":1498},{"className":590,"code":1497,"language":592,"meta":393,"style":393},"import mariadb\nimport numpy as np\nfrom openai import OpenAI\n\nclient = OpenAI()\n\ndef embed(text):\n    vec = client.embeddings.create(input=text, model=\"text-embedding-3-small\").data[0].embedding\n    return np.asarray(vec, dtype=np.float32).tobytes()\n\n# Create database and table if they don't exist\nconn = mariadb.connect(host=\"127.0.0.1\", port=3306, user=\"root\", password=\"\")\ncur = conn.cursor()\ncur.execute(\"CREATE DATABASE IF NOT EXISTS ragdb\")\ncur.execute(\"USE ragdb\")\ncur.execute(\"\"\"\n    CREATE TABLE IF NOT EXISTS chunks (\n        chunk_id  BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,\n        content   TEXT NOT NULL,\n        embedding VECTOR(1536) NOT NULL,\n        VECTOR INDEX (embedding) DISTANCE=cosine\n    ) ENGINE=InnoDB\n\"\"\")\nconn.commit()\n\n# Store a document chunk\ncur.execute(\n    \"INSERT INTO chunks (content, embedding) VALUES (?, ?)\",\n    (\"MariaDB Vector stores embeddings natively\", embed(\"MariaDB Vector stores embeddings natively\"))\n)\nconn.commit()\n\n# Retrieve top-5 nearest chunks for a user question\nquestion_vec = embed(\"How does MariaDB store vectors?\")\ncur.execute(\"\"\"\n    SELECT content, VEC_DISTANCE_COSINE(embedding, ?) AS distance\n    FROM chunks\n    ORDER BY distance\n    LIMIT 5\n\"\"\", (question_vec,))\ncontext = \"\\n\".join(row[0] for row in cur.fetchall())\n# Pass `context` to your LLM as the retrieved context for the answer\n",[1499],{"type":37,"tag":76,"props":1500,"children":1501},{"__ignoreMap":393},[1502,1510,1517,1525,1534,1542,1549,1557,1565,1573,1581,1590,1599,1608,1617,1626,1635,1644,1653,1662,1671,1680,1689,1698,1707,1715,1724,1732,1741,1750,1758,1766,1774,1783,1792,1800,1808,1817,1826,1835,1844,1853],{"type":37,"tag":399,"props":1503,"children":1504},{"class":401,"line":402},[1505],{"type":37,"tag":399,"props":1506,"children":1507},{},[1508],{"type":43,"value":1509},"import mariadb\n",{"type":37,"tag":399,"props":1511,"children":1512},{"class":401,"line":24},[1513],{"type":37,"tag":399,"props":1514,"children":1515},{},[1516],{"type":43,"value":604},{"type":37,"tag":399,"props":1518,"children":1519},{"class":401,"line":419},[1520],{"type":37,"tag":399,"props":1521,"children":1522},{},[1523],{"type":43,"value":1524},"from openai import OpenAI\n",{"type":37,"tag":399,"props":1526,"children":1527},{"class":401,"line":428},[1528],{"type":37,"tag":399,"props":1529,"children":1531},{"emptyLinePlaceholder":1530},true,[1532],{"type":43,"value":1533},"\n",{"type":37,"tag":399,"props":1535,"children":1536},{"class":401,"line":437},[1537],{"type":37,"tag":399,"props":1538,"children":1539},{},[1540],{"type":43,"value":1541},"client = OpenAI()\n",{"type":37,"tag":399,"props":1543,"children":1544},{"class":401,"line":446},[1545],{"type":37,"tag":399,"props":1546,"children":1547},{"emptyLinePlaceholder":1530},[1548],{"type":43,"value":1533},{"type":37,"tag":399,"props":1550,"children":1551},{"class":401,"line":1445},[1552],{"type":37,"tag":399,"props":1553,"children":1554},{},[1555],{"type":43,"value":1556},"def embed(text):\n",{"type":37,"tag":399,"props":1558,"children":1559},{"class":401,"line":1454},[1560],{"type":37,"tag":399,"props":1561,"children":1562},{},[1563],{"type":43,"value":1564},"    vec = client.embeddings.create(input=text, model=\"text-embedding-3-small\").data[0].embedding\n",{"type":37,"tag":399,"props":1566,"children":1567},{"class":401,"line":20},[1568],{"type":37,"tag":399,"props":1569,"children":1570},{},[1571],{"type":43,"value":1572},"    return np.asarray(vec, dtype=np.float32).tobytes()\n",{"type":37,"tag":399,"props":1574,"children":1576},{"class":401,"line":1575},10,[1577],{"type":37,"tag":399,"props":1578,"children":1579},{"emptyLinePlaceholder":1530},[1580],{"type":43,"value":1533},{"type":37,"tag":399,"props":1582,"children":1584},{"class":401,"line":1583},11,[1585],{"type":37,"tag":399,"props":1586,"children":1587},{},[1588],{"type":43,"value":1589},"# Create database and table if they don't exist\n",{"type":37,"tag":399,"props":1591,"children":1593},{"class":401,"line":1592},12,[1594],{"type":37,"tag":399,"props":1595,"children":1596},{},[1597],{"type":43,"value":1598},"conn = mariadb.connect(host=\"127.0.0.1\", port=3306, user=\"root\", password=\"\")\n",{"type":37,"tag":399,"props":1600,"children":1602},{"class":401,"line":1601},13,[1603],{"type":37,"tag":399,"props":1604,"children":1605},{},[1606],{"type":43,"value":1607},"cur = conn.cursor()\n",{"type":37,"tag":399,"props":1609,"children":1611},{"class":401,"line":1610},14,[1612],{"type":37,"tag":399,"props":1613,"children":1614},{},[1615],{"type":43,"value":1616},"cur.execute(\"CREATE DATABASE IF NOT EXISTS ragdb\")\n",{"type":37,"tag":399,"props":1618,"children":1620},{"class":401,"line":1619},15,[1621],{"type":37,"tag":399,"props":1622,"children":1623},{},[1624],{"type":43,"value":1625},"cur.execute(\"USE ragdb\")\n",{"type":37,"tag":399,"props":1627,"children":1629},{"class":401,"line":1628},16,[1630],{"type":37,"tag":399,"props":1631,"children":1632},{},[1633],{"type":43,"value":1634},"cur.execute(\"\"\"\n",{"type":37,"tag":399,"props":1636,"children":1638},{"class":401,"line":1637},17,[1639],{"type":37,"tag":399,"props":1640,"children":1641},{},[1642],{"type":43,"value":1643},"    CREATE TABLE IF NOT EXISTS chunks (\n",{"type":37,"tag":399,"props":1645,"children":1647},{"class":401,"line":1646},18,[1648],{"type":37,"tag":399,"props":1649,"children":1650},{},[1651],{"type":43,"value":1652},"        chunk_id  BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,\n",{"type":37,"tag":399,"props":1654,"children":1656},{"class":401,"line":1655},19,[1657],{"type":37,"tag":399,"props":1658,"children":1659},{},[1660],{"type":43,"value":1661},"        content   TEXT NOT NULL,\n",{"type":37,"tag":399,"props":1663,"children":1665},{"class":401,"line":1664},20,[1666],{"type":37,"tag":399,"props":1667,"children":1668},{},[1669],{"type":43,"value":1670},"        embedding VECTOR(1536) NOT NULL,\n",{"type":37,"tag":399,"props":1672,"children":1674},{"class":401,"line":1673},21,[1675],{"type":37,"tag":399,"props":1676,"children":1677},{},[1678],{"type":43,"value":1679},"        VECTOR INDEX (embedding) DISTANCE=cosine\n",{"type":37,"tag":399,"props":1681,"children":1683},{"class":401,"line":1682},22,[1684],{"type":37,"tag":399,"props":1685,"children":1686},{},[1687],{"type":43,"value":1688},"    ) ENGINE=InnoDB\n",{"type":37,"tag":399,"props":1690,"children":1692},{"class":401,"line":1691},23,[1693],{"type":37,"tag":399,"props":1694,"children":1695},{},[1696],{"type":43,"value":1697},"\"\"\")\n",{"type":37,"tag":399,"props":1699,"children":1701},{"class":401,"line":1700},24,[1702],{"type":37,"tag":399,"props":1703,"children":1704},{},[1705],{"type":43,"value":1706},"conn.commit()\n",{"type":37,"tag":399,"props":1708,"children":1710},{"class":401,"line":1709},25,[1711],{"type":37,"tag":399,"props":1712,"children":1713},{"emptyLinePlaceholder":1530},[1714],{"type":43,"value":1533},{"type":37,"tag":399,"props":1716,"children":1718},{"class":401,"line":1717},26,[1719],{"type":37,"tag":399,"props":1720,"children":1721},{},[1722],{"type":43,"value":1723},"# Store a document chunk\n",{"type":37,"tag":399,"props":1725,"children":1727},{"class":401,"line":1726},27,[1728],{"type":37,"tag":399,"props":1729,"children":1730},{},[1731],{"type":43,"value":612},{"type":37,"tag":399,"props":1733,"children":1735},{"class":401,"line":1734},28,[1736],{"type":37,"tag":399,"props":1737,"children":1738},{},[1739],{"type":43,"value":1740},"    \"INSERT INTO chunks (content, embedding) VALUES (?, ?)\",\n",{"type":37,"tag":399,"props":1742,"children":1744},{"class":401,"line":1743},29,[1745],{"type":37,"tag":399,"props":1746,"children":1747},{},[1748],{"type":43,"value":1749},"    (\"MariaDB Vector stores embeddings natively\", embed(\"MariaDB Vector stores embeddings natively\"))\n",{"type":37,"tag":399,"props":1751,"children":1753},{"class":401,"line":1752},30,[1754],{"type":37,"tag":399,"props":1755,"children":1756},{},[1757],{"type":43,"value":636},{"type":37,"tag":399,"props":1759,"children":1761},{"class":401,"line":1760},31,[1762],{"type":37,"tag":399,"props":1763,"children":1764},{},[1765],{"type":43,"value":1706},{"type":37,"tag":399,"props":1767,"children":1769},{"class":401,"line":1768},32,[1770],{"type":37,"tag":399,"props":1771,"children":1772},{"emptyLinePlaceholder":1530},[1773],{"type":43,"value":1533},{"type":37,"tag":399,"props":1775,"children":1777},{"class":401,"line":1776},33,[1778],{"type":37,"tag":399,"props":1779,"children":1780},{},[1781],{"type":43,"value":1782},"# Retrieve top-5 nearest chunks for a user question\n",{"type":37,"tag":399,"props":1784,"children":1786},{"class":401,"line":1785},34,[1787],{"type":37,"tag":399,"props":1788,"children":1789},{},[1790],{"type":43,"value":1791},"question_vec = embed(\"How does MariaDB store vectors?\")\n",{"type":37,"tag":399,"props":1793,"children":1795},{"class":401,"line":1794},35,[1796],{"type":37,"tag":399,"props":1797,"children":1798},{},[1799],{"type":43,"value":1634},{"type":37,"tag":399,"props":1801,"children":1803},{"class":401,"line":1802},36,[1804],{"type":37,"tag":399,"props":1805,"children":1806},{},[1807],{"type":43,"value":1216},{"type":37,"tag":399,"props":1809,"children":1811},{"class":401,"line":1810},37,[1812],{"type":37,"tag":399,"props":1813,"children":1814},{},[1815],{"type":43,"value":1816},"    FROM chunks\n",{"type":37,"tag":399,"props":1818,"children":1820},{"class":401,"line":1819},38,[1821],{"type":37,"tag":399,"props":1822,"children":1823},{},[1824],{"type":43,"value":1825},"    ORDER BY distance\n",{"type":37,"tag":399,"props":1827,"children":1829},{"class":401,"line":1828},39,[1830],{"type":37,"tag":399,"props":1831,"children":1832},{},[1833],{"type":43,"value":1834},"    LIMIT 5\n",{"type":37,"tag":399,"props":1836,"children":1838},{"class":401,"line":1837},40,[1839],{"type":37,"tag":399,"props":1840,"children":1841},{},[1842],{"type":43,"value":1843},"\"\"\", (question_vec,))\n",{"type":37,"tag":399,"props":1845,"children":1847},{"class":401,"line":1846},41,[1848],{"type":37,"tag":399,"props":1849,"children":1850},{},[1851],{"type":43,"value":1852},"context = \"\\n\".join(row[0] for row in cur.fetchall())\n",{"type":37,"tag":399,"props":1854,"children":1856},{"class":401,"line":1855},42,[1857],{"type":37,"tag":399,"props":1858,"children":1859},{},[1860],{"type":43,"value":1861},"# Pass `context` to your LLM as the retrieved context for the answer\n",{"type":37,"tag":46,"props":1863,"children":1864},{},[1865,1867,1872,1874,1880,1882,1888],{"type":43,"value":1866},"The ",{"type":37,"tag":76,"props":1868,"children":1870},{"className":1869},[],[1871],{"type":43,"value":8},{"type":43,"value":1873}," connector (",{"type":37,"tag":76,"props":1875,"children":1877},{"className":1876},[],[1878],{"type":43,"value":1879},"pip install mariadb",{"type":43,"value":1881},") is the official Python driver. On big-endian hosts, use ",{"type":37,"tag":76,"props":1883,"children":1885},{"className":1884},[],[1886],{"type":43,"value":1887},"dtype=\"\u003Cf4\"",{"type":43,"value":1889}," to force little-endian.",{"type":37,"tag":56,"props":1891,"children":1893},{"id":1892},"framework-integrations",[1894],{"type":43,"value":1895},"Framework Integrations",{"type":37,"tag":46,"props":1897,"children":1898},{},[1899],{"type":43,"value":1900},"MariaDB Vector is integrated with major AI frameworks. Use these instead of writing raw SQL when building applications:",{"type":37,"tag":205,"props":1902,"children":1903},{},[1904,1925],{"type":37,"tag":209,"props":1905,"children":1906},{},[1907],{"type":37,"tag":213,"props":1908,"children":1909},{},[1910,1915,1920],{"type":37,"tag":217,"props":1911,"children":1912},{},[1913],{"type":43,"value":1914},"Framework",{"type":37,"tag":217,"props":1916,"children":1917},{},[1918],{"type":43,"value":1919},"Language",{"type":37,"tag":217,"props":1921,"children":1922},{},[1923],{"type":43,"value":1924},"Link",{"type":37,"tag":228,"props":1926,"children":1927},{},[1928,1950,1968,1986,2002,2018],{"type":37,"tag":213,"props":1929,"children":1930},{},[1931,1936,1941],{"type":37,"tag":235,"props":1932,"children":1933},{},[1934],{"type":43,"value":1935},"LangChain",{"type":37,"tag":235,"props":1937,"children":1938},{},[1939],{"type":43,"value":1940},"Python",{"type":37,"tag":235,"props":1942,"children":1943},{},[1944],{"type":37,"tag":76,"props":1945,"children":1947},{"className":1946},[],[1948],{"type":43,"value":1949},"pip install langchain-mariadb",{"type":37,"tag":213,"props":1951,"children":1952},{},[1953,1958,1963],{"type":37,"tag":235,"props":1954,"children":1955},{},[1956],{"type":43,"value":1957},"LangChain.js",{"type":37,"tag":235,"props":1959,"children":1960},{},[1961],{"type":43,"value":1962},"Node.js",{"type":37,"tag":235,"props":1964,"children":1965},{},[1966],{"type":43,"value":1967},"Built-in MariaDB vector store",{"type":37,"tag":213,"props":1969,"children":1970},{},[1971,1976,1981],{"type":37,"tag":235,"props":1972,"children":1973},{},[1974],{"type":43,"value":1975},"LangChain4j",{"type":37,"tag":235,"props":1977,"children":1978},{},[1979],{"type":43,"value":1980},"Java",{"type":37,"tag":235,"props":1982,"children":1983},{},[1984],{"type":43,"value":1985},"Built-in MariaDB embedding store",{"type":37,"tag":213,"props":1987,"children":1988},{},[1989,1994,1998],{"type":37,"tag":235,"props":1990,"children":1991},{},[1992],{"type":43,"value":1993},"LlamaIndex",{"type":37,"tag":235,"props":1995,"children":1996},{},[1997],{"type":43,"value":1940},{"type":37,"tag":235,"props":1999,"children":2000},{},[2001],{"type":43,"value":1967},{"type":37,"tag":213,"props":2003,"children":2004},{},[2005,2010,2014],{"type":37,"tag":235,"props":2006,"children":2007},{},[2008],{"type":43,"value":2009},"Spring AI",{"type":37,"tag":235,"props":2011,"children":2012},{},[2013],{"type":43,"value":1980},{"type":37,"tag":235,"props":2015,"children":2016},{},[2017],{"type":43,"value":1967},{"type":37,"tag":213,"props":2019,"children":2020},{},[2021,2026,2030],{"type":37,"tag":235,"props":2022,"children":2023},{},[2024],{"type":43,"value":2025},"MariaDB MCP Server",{"type":37,"tag":235,"props":2027,"children":2028},{},[2029],{"type":43,"value":1940},{"type":37,"tag":235,"props":2031,"children":2032},{},[2033],{"type":37,"tag":157,"props":2034,"children":2037},{"href":2035,"rel":2036},"https:\u002F\u002Fgithub.com\u002FMariaDB\u002Fmcp",[161],[2038],{"type":43,"value":2039},"github.com\u002Fmariadb\u002Fmcp",{"type":37,"tag":46,"props":2041,"children":2042},{},[2043,2045,2051,2052,2058,2060,2065],{"type":43,"value":2044},"When using frameworks, you typically configure a connection string and the framework handles ",{"type":37,"tag":76,"props":2046,"children":2048},{"className":2047},[],[2049],{"type":43,"value":2050},"VEC_FromText",{"type":43,"value":112},{"type":37,"tag":76,"props":2053,"children":2055},{"className":2054},[],[2056],{"type":43,"value":2057},"VEC_DISTANCE",{"type":43,"value":2059},", and ",{"type":37,"tag":76,"props":2061,"children":2063},{"className":2062},[],[2064],{"type":43,"value":280},{"type":43,"value":2066}," for you.",{"type":37,"tag":56,"props":2068,"children":2070},{"id":2069},"choosing-an-embedding-model",[2071],{"type":43,"value":2072},"Choosing an Embedding Model",{"type":37,"tag":46,"props":2074,"children":2075},{},[2076],{"type":43,"value":2077},"The embedding model determines vector quality. Some practical guidance:",{"type":37,"tag":509,"props":2079,"children":2080},{},[2081,2099,2120,2130,2140],{"type":37,"tag":513,"props":2082,"children":2083},{},[2084,2089,2091,2097],{"type":37,"tag":68,"props":2085,"children":2086},{},[2087],{"type":43,"value":2088},"Start with a sentence-transformer model",{"type":43,"value":2090}," (e.g., ",{"type":37,"tag":76,"props":2092,"children":2094},{"className":2093},[],[2095],{"type":43,"value":2096},"all-MiniLM-L6-v2",{"type":43,"value":2098},", 384 dimensions) for prototyping. Free, fast, runs locally.",{"type":37,"tag":513,"props":2100,"children":2101},{},[2102,2113,2115],{"type":37,"tag":68,"props":2103,"children":2104},{},[2105,2107],{"type":43,"value":2106},"OpenAI ",{"type":37,"tag":76,"props":2108,"children":2110},{"className":2109},[],[2111],{"type":43,"value":2112},"text-embedding-3-small",{"type":43,"value":2114}," (1536 dimensions) is a solid production choice if you're already using OpenAI. ",{"type":37,"tag":50,"props":2116,"children":2117},{},[2118],{"type":43,"value":2119},"(Dimensions correct as of May 2026 — verify against current model docs.)",{"type":37,"tag":513,"props":2121,"children":2122},{},[2123,2128],{"type":37,"tag":68,"props":2124,"children":2125},{},[2126],{"type":43,"value":2127},"Match dimensions to your VECTOR(n) column.",{"type":43,"value":2129}," A mismatch will cause insert errors.",{"type":37,"tag":513,"props":2131,"children":2132},{},[2133,2138],{"type":37,"tag":68,"props":2134,"children":2135},{},[2136],{"type":43,"value":2137},"Never mix embeddings from different models",{"type":43,"value":2139}," in the same column. Distances between vectors from different models are meaningless.",{"type":37,"tag":513,"props":2141,"children":2142},{},[2143,2148],{"type":37,"tag":68,"props":2144,"children":2145},{},[2146],{"type":43,"value":2147},"Cosine distance is the standard",{"type":43,"value":2149}," for most text embedding models. Check your model's documentation.",{"type":37,"tag":56,"props":2151,"children":2153},{"id":2152},"performance-notes",[2154],{"type":43,"value":2155},"Performance Notes",{"type":37,"tag":509,"props":2157,"children":2158},{},[2159,2171,2181,2191,2203,2213],{"type":37,"tag":513,"props":2160,"children":2161},{},[2162,2164,2169],{"type":43,"value":2163},"MariaDB Vector uses ",{"type":37,"tag":68,"props":2165,"children":2166},{},[2167],{"type":43,"value":2168},"SIMD hardware optimizations",{"type":43,"value":2170}," (AVX2, AVX512 on Intel; NEON on ARM; VSX on IBM Power10). No configuration needed — it detects and uses the best available instruction set.",{"type":37,"tag":513,"props":2172,"children":2173},{},[2174,2179],{"type":37,"tag":68,"props":2175,"children":2176},{},[2177],{"type":43,"value":2178},"Faster vector distance via extrapolation",{"type":43,"value":2180}," (12.1+, MDEV-36205) — vector search is 30–50% faster on the same data and recall, with no schema or index changes required. The optimization applies automatically to vectors that can be gradually truncated to trade recall for speed (e.g. Matryoshka-style embeddings from OpenAI).",{"type":37,"tag":513,"props":2182,"children":2183},{},[2184,2189],{"type":37,"tag":68,"props":2185,"children":2186},{},[2187],{"type":43,"value":2188},"Multi-connection scalability",{"type":43,"value":2190}," is a strength. Benchmark results show MariaDB Vector scales well with concurrent queries, outperforming some dedicated vector databases in multi-threaded scenarios.",{"type":37,"tag":513,"props":2192,"children":2193},{},[2194,2196,2201],{"type":43,"value":2195},"For large datasets (millions of vectors), tune the ",{"type":37,"tag":68,"props":2197,"children":2198},{},[2199],{"type":43,"value":2200},"M parameter",{"type":43,"value":2202}," upward and ensure sufficient memory for the index.",{"type":37,"tag":513,"props":2204,"children":2205},{},[2206,2211],{"type":37,"tag":68,"props":2207,"children":2208},{},[2209],{"type":43,"value":2210},"Bulk inserts",{"type":43,"value":2212},": load data first, then create the vector index. This is significantly faster than inserting into an already-indexed table.",{"type":37,"tag":513,"props":2214,"children":2215},{},[2216,2221,2223,2229,2231,2236],{"type":37,"tag":68,"props":2217,"children":2218},{},[2219],{"type":43,"value":2220},"Bind embeddings as binary",{"type":43,"value":2222}," (",{"type":37,"tag":76,"props":2224,"children":2226},{"className":2225},[],[2227],{"type":43,"value":2228},"float32.tobytes()",{"type":43,"value":2230},"), not ",{"type":37,"tag":76,"props":2232,"children":2234},{"className":2233},[],[2235],{"type":43,"value":585},{"type":43,"value":2237},". ~5× faster, ~5× smaller wire payload, byte-identical storage.",{"type":37,"tag":198,"props":2239,"children":2241},{"id":2240},"tuning-mhnsw-system-variables",[2242],{"type":43,"value":2243},"Tuning: mhnsw System Variables",{"type":37,"tag":46,"props":2245,"children":2246},{},[2247],{"type":43,"value":2248},"These session\u002Fglobal variables let you tune search quality and memory at runtime without rebuilding the index:",{"type":37,"tag":509,"props":2250,"children":2251},{},[2252,2289,2310],{"type":37,"tag":513,"props":2253,"children":2254},{},[2255,2264,2266,2272,2274,2280,2282,2287],{"type":37,"tag":68,"props":2256,"children":2257},{},[2258],{"type":37,"tag":76,"props":2259,"children":2261},{"className":2260},[],[2262],{"type":43,"value":2263},"mhnsw_ef_search",{"type":43,"value":2265}," (default: ",{"type":37,"tag":76,"props":2267,"children":2269},{"className":2268},[],[2270],{"type":43,"value":2271},"20",{"type":43,"value":2273},") — minimum candidates considered for ",{"type":37,"tag":76,"props":2275,"children":2277},{"className":2276},[],[2278],{"type":43,"value":2279},"ORDER BY … LIMIT N",{"type":43,"value":2281}," queries. Raise this if recall is low at small ",{"type":37,"tag":76,"props":2283,"children":2285},{"className":2284},[],[2286],{"type":43,"value":280},{"type":43,"value":2288}," values; lower it to trade recall for speed.",{"type":37,"tag":513,"props":2290,"children":2291},{},[2292,2301,2302,2308],{"type":37,"tag":68,"props":2293,"children":2294},{},[2295],{"type":37,"tag":76,"props":2296,"children":2298},{"className":2297},[],[2299],{"type":43,"value":2300},"mhnsw_max_cache_size",{"type":43,"value":2265},{"type":37,"tag":76,"props":2303,"children":2305},{"className":2304},[],[2306],{"type":43,"value":2307},"16777216",{"type":43,"value":2309}," \u002F 16 MB, global only) — per-index in-memory cache cap. For best performance the entire vector graph should fit in this cache; size it to match your index.",{"type":37,"tag":513,"props":2311,"children":2312},{},[2313,2322,2323,2329,2331,2340,2341,2346,2348,2353,2354,2359,2361,2366],{"type":37,"tag":68,"props":2314,"children":2315},{},[2316],{"type":37,"tag":76,"props":2317,"children":2319},{"className":2318},[],[2320],{"type":43,"value":2321},"mhnsw_default_m",{"type":43,"value":2265},{"type":37,"tag":76,"props":2324,"children":2326},{"className":2325},[],[2327],{"type":43,"value":2328},"6",{"type":43,"value":2330},") and ",{"type":37,"tag":68,"props":2332,"children":2333},{},[2334],{"type":37,"tag":76,"props":2335,"children":2337},{"className":2336},[],[2338],{"type":43,"value":2339},"mhnsw_default_distance",{"type":43,"value":2265},{"type":37,"tag":76,"props":2342,"children":2344},{"className":2343},[],[2345],{"type":43,"value":528},{"type":43,"value":2347},") set the implicit values used when ",{"type":37,"tag":76,"props":2349,"children":2351},{"className":2350},[],[2352],{"type":43,"value":561},{"type":43,"value":366},{"type":37,"tag":76,"props":2355,"children":2357},{"className":2356},[],[2358],{"type":43,"value":520},{"type":43,"value":2360}," are omitted from a ",{"type":37,"tag":76,"props":2362,"children":2364},{"className":2363},[],[2365],{"type":43,"value":89},{"type":43,"value":2367}," declaration.",{"type":37,"tag":56,"props":2369,"children":2371},{"id":2370},"sources",[2372],{"type":43,"value":2373},"Sources",{"type":37,"tag":509,"props":2375,"children":2376},{},[2377,2389,2401,2412,2424,2435,2445,2455,2467,2478,2488],{"type":37,"tag":513,"props":2378,"children":2379},{},[2380,2387],{"type":37,"tag":157,"props":2381,"children":2384},{"href":2382,"rel":2383},"https:\u002F\u002Fmariadb.com\u002Fdocs\u002Fserver\u002Freference\u002Fsql-structure\u002Fvectors\u002Fvector-overview",[161],[2385],{"type":43,"value":2386},"Vector Overview",{"type":43,"value":2388}," — official docs entry point",{"type":37,"tag":513,"props":2390,"children":2391},{},[2392,2399],{"type":37,"tag":157,"props":2393,"children":2396},{"href":2394,"rel":2395},"https:\u002F\u002Fmariadb.com\u002Fdocs\u002Fserver\u002Freference\u002Fsql-structure\u002Fvectors\u002Fcreate-table-with-vectors",[161],[2397],{"type":43,"value":2398},"CREATE TABLE with Vectors",{"type":43,"value":2400}," — index options, NOT NULL requirement, limitations",{"type":37,"tag":513,"props":2402,"children":2403},{},[2404,2410],{"type":37,"tag":157,"props":2405,"children":2408},{"href":2406,"rel":2407},"https:\u002F\u002Fmariadb.com\u002Fdocs\u002Fserver\u002Freference\u002Fsql-functions\u002Fvector-functions\u002Fvec_fromtext",[161],[2409],{"type":43,"value":2050},{"type":43,"value":2411}," — converts JSON float array to binary VECTOR",{"type":37,"tag":513,"props":2413,"children":2414},{},[2415,2422],{"type":37,"tag":157,"props":2416,"children":2419},{"href":2417,"rel":2418},"https:\u002F\u002Fmariadb.com\u002Fdocs\u002Fserver\u002Freference\u002Fsql-functions\u002Fvector-functions\u002Fvec_totext",[161],[2420],{"type":43,"value":2421},"VEC_ToText",{"type":43,"value":2423}," — converts binary VECTOR to JSON float array",{"type":37,"tag":513,"props":2425,"children":2426},{},[2427,2433],{"type":37,"tag":157,"props":2428,"children":2431},{"href":2429,"rel":2430},"https:\u002F\u002Fmariadb.com\u002Fdocs\u002Fserver\u002Freference\u002Fsql-functions\u002Fvector-functions\u002Fvector-functions-vec_distance",[161],[2432],{"type":43,"value":2057},{"type":43,"value":2434}," — generic distance, requires index",{"type":37,"tag":513,"props":2436,"children":2437},{},[2438],{"type":37,"tag":157,"props":2439,"children":2442},{"href":2440,"rel":2441},"https:\u002F\u002Fmariadb.com\u002Fdocs\u002Fserver\u002Freference\u002Fsql-functions\u002Fvector-functions\u002Fvec_distance_euclidean",[161],[2443],{"type":43,"value":2444},"VEC_DISTANCE_EUCLIDEAN",{"type":37,"tag":513,"props":2446,"children":2447},{},[2448],{"type":37,"tag":157,"props":2449,"children":2452},{"href":2450,"rel":2451},"https:\u002F\u002Fmariadb.com\u002Fdocs\u002Fserver\u002Freference\u002Fsql-functions\u002Fvector-functions\u002Fvec_distance_cosine",[161],[2453],{"type":43,"value":2454},"VEC_DISTANCE_COSINE",{"type":37,"tag":513,"props":2456,"children":2457},{},[2458,2465],{"type":37,"tag":157,"props":2459,"children":2462},{"href":2460,"rel":2461},"https:\u002F\u002Fmariadb.org\u002Frag-with-mariadb-vector\u002F",[161],[2463],{"type":43,"value":2464},"RAG with MariaDB Vector tutorial",{"type":43,"value":2466}," — end-to-end Python + OpenAI example",{"type":37,"tag":513,"props":2468,"children":2469},{},[2470,2476],{"type":37,"tag":157,"props":2471,"children":2473},{"href":1377,"rel":2472},[161],[2474],{"type":43,"value":2475},"Hybrid search with RRF",{"type":43,"value":2477}," — merge full-text and vector ranked lists",{"type":37,"tag":513,"props":2479,"children":2480},{},[2481],{"type":37,"tag":157,"props":2482,"children":2485},{"href":2483,"rel":2484},"https:\u002F\u002Fmariadb.org\u002Fprojects\u002Fmariadb-vector\u002F",[161],[2486],{"type":43,"value":2487},"MariaDB Vector project page",{"type":37,"tag":513,"props":2489,"children":2490},{},[2491],{"type":37,"tag":157,"props":2492,"children":2494},{"href":2035,"rel":2493},[161],[2495],{"type":43,"value":2025},{"type":37,"tag":46,"props":2497,"children":2498},{},[2499],{"type":37,"tag":50,"props":2500,"children":2501},{},[2502,2504,2511],{"type":43,"value":2503},"For topics not covered here, see the official MariaDB documentation at ",{"type":37,"tag":157,"props":2505,"children":2508},{"href":2506,"rel":2507},"https:\u002F\u002Fmariadb.com\u002Fdocs",[161],[2509],{"type":43,"value":2510},"mariadb.com\u002Fdocs",{"type":43,"value":989},{"type":37,"tag":2513,"props":2514,"children":2515},"style",{},[2516],{"type":43,"value":2517},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"items":2519,"total":1454},[2520,2534,2546,2557,2569,2587,2593],{"slug":2521,"name":2521,"fn":2522,"description":2523,"org":2524,"tags":2525,"stars":20,"repoUrl":21,"updatedAt":2533},"mariadb-features","optimize and manage MariaDB databases","MariaDB-specific features and capabilities that go beyond standard MySQL. Use when evaluating MariaDB, optimizing an existing MariaDB application, reviewing code or schema for MariaDB improvements, asking what MariaDB can do that other databases cannot, or migrating from Oracle to MariaDB. Also use when the user asks what could be improved in how a codebase uses MariaDB, or asks about MariaDB advantages over MySQL or PostgreSQL.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[2526,2527,2528,2531],{"name":15,"slug":16,"type":13},{"name":9,"slug":8,"type":13},{"name":2529,"slug":2530,"type":13},"Performance","performance",{"name":2532,"slug":392,"type":13},"SQL","2026-07-16T06:01:55.988338",{"slug":2535,"name":2535,"fn":2536,"description":2537,"org":2538,"tags":2539,"stars":20,"repoUrl":21,"updatedAt":2545},"mariadb-mcp","connect AI agents to MariaDB","How to connect AI agents to MariaDB using the Model Context Protocol (MCP). Use when setting up MCP with MariaDB, connecting Claude Code, Cursor, or other AI tools to a MariaDB database, enabling natural language database queries, or building AI applications that need live database access. The MariaDB MCP Server lets agents query schemas, run read-only SQL, and perform semantic search against MariaDB.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[2540,2541,2542],{"name":15,"slug":16,"type":13},{"name":9,"slug":8,"type":13},{"name":2543,"slug":2544,"type":13},"MCP","mcp","2026-07-13T06:14:00.682655",{"slug":2547,"name":2547,"fn":2548,"description":2549,"org":2550,"tags":2551,"stars":20,"repoUrl":21,"updatedAt":2556},"mariadb-query-optimization","optimize MariaDB database queries","Best practices for query optimization in MariaDB — indexing strategies, EXPLAIN analysis, pagination, histogram statistics, and MariaDB-specific optimizer settings. Use when diagnosing slow queries, designing indexes, reviewing schema or query performance, or when queries involve large tables, pagination, GROUP BY, or ORDER BY. Also use when the user asks about MariaDB query performance, EXPLAIN output, or optimizer behavior.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[2552,2553,2554,2555],{"name":15,"slug":16,"type":13},{"name":9,"slug":8,"type":13},{"name":2529,"slug":2530,"type":13},{"name":2532,"slug":392,"type":13},"2026-07-13T06:14:12.656074",{"slug":2558,"name":2558,"fn":2559,"description":2560,"org":2561,"tags":2562,"stars":20,"repoUrl":21,"updatedAt":2568},"mariadb-replication-and-ha","configure MariaDB replication and high availability","Best practices for MariaDB replication and high availability — Galera Cluster, GTID replication, semi-synchronous replication, parallel replication, and application patterns for HA environments. Use when setting up replication, designing applications for HA, working with Galera Cluster, asking about MariaDB GTID, handling replication lag in application code, or choosing between replication topologies. IMPORTANT — MariaDB GTID format is incompatible with MySQL GTID, and Galera Cluster needs no server plugin to load but does require the separate galera wsrep provider library (galera-4).",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[2563,2566,2567],{"name":2564,"slug":2565,"type":13},"Architecture","architecture",{"name":15,"slug":16,"type":13},{"name":9,"slug":8,"type":13},"2026-07-13T06:14:13.989369",{"slug":2570,"name":2570,"fn":2571,"description":2572,"org":2573,"tags":2574,"stars":20,"repoUrl":21,"updatedAt":2586},"mariadb-system-versioned-tables","implement MariaDB system-versioned tables","Best practices for MariaDB system-versioned (temporal) tables — automatic row history built into the database. Use when tracking data changes over time, implementing audit trails, meeting GDPR or compliance requirements, doing point-in-time queries, or when the user asks about row history, data versioning, temporal tables, or querying past data states in MariaDB. This feature is unique to MariaDB among MySQL-compatible databases.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[2575,2578,2581,2582,2585],{"name":2576,"slug":2577,"type":13},"Audit","audit",{"name":2579,"slug":2580,"type":13},"Compliance","compliance",{"name":15,"slug":16,"type":13},{"name":2583,"slug":2584,"type":13},"GDPR","gdpr",{"name":9,"slug":8,"type":13},"2026-07-13T06:14:16.779878",{"slug":4,"name":4,"fn":5,"description":6,"org":2588,"tags":2589,"stars":20,"repoUrl":21,"updatedAt":22},{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[2590,2591,2592],{"name":15,"slug":16,"type":13},{"name":9,"slug":8,"type":13},{"name":18,"slug":19,"type":13},{"slug":2594,"name":2594,"fn":2595,"description":2596,"org":2597,"tags":2598,"stars":20,"repoUrl":21,"updatedAt":2605},"mysql-to-mariadb","migrate applications from MySQL to MariaDB","Compatibility guide for developers moving from MySQL to MariaDB, and for developers with MySQL experience working with MariaDB. Use when migrating a MySQL application to MariaDB, when MySQL syntax or habits cause unexpected behavior in MariaDB, when asking about MySQL\u002FMariaDB compatibility, or when adapting code written for MySQL to run on MariaDB. IMPORTANT — MariaDB diverges significantly from MySQL 8.0 and is not a simple drop-in replacement for modern MySQL. Authentication plugins, JSON handling, GTID replication, and several SQL features differ in important ways.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[2599,2600,2601,2602],{"name":15,"slug":16,"type":13},{"name":9,"slug":8,"type":13},{"name":18,"slug":19,"type":13},{"name":2603,"slug":2604,"type":13},"MySQL","mysql","2026-07-13T06:14:08.675338",{"items":2607,"total":1454},[2608,2615,2621,2628,2634,2642,2648,2655],{"slug":2521,"name":2521,"fn":2522,"description":2523,"org":2609,"tags":2610,"stars":20,"repoUrl":21,"updatedAt":2533},{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[2611,2612,2613,2614],{"name":15,"slug":16,"type":13},{"name":9,"slug":8,"type":13},{"name":2529,"slug":2530,"type":13},{"name":2532,"slug":392,"type":13},{"slug":2535,"name":2535,"fn":2536,"description":2537,"org":2616,"tags":2617,"stars":20,"repoUrl":21,"updatedAt":2545},{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[2618,2619,2620],{"name":15,"slug":16,"type":13},{"name":9,"slug":8,"type":13},{"name":2543,"slug":2544,"type":13},{"slug":2547,"name":2547,"fn":2548,"description":2549,"org":2622,"tags":2623,"stars":20,"repoUrl":21,"updatedAt":2556},{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[2624,2625,2626,2627],{"name":15,"slug":16,"type":13},{"name":9,"slug":8,"type":13},{"name":2529,"slug":2530,"type":13},{"name":2532,"slug":392,"type":13},{"slug":2558,"name":2558,"fn":2559,"description":2560,"org":2629,"tags":2630,"stars":20,"repoUrl":21,"updatedAt":2568},{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[2631,2632,2633],{"name":2564,"slug":2565,"type":13},{"name":15,"slug":16,"type":13},{"name":9,"slug":8,"type":13},{"slug":2570,"name":2570,"fn":2571,"description":2572,"org":2635,"tags":2636,"stars":20,"repoUrl":21,"updatedAt":2586},{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[2637,2638,2639,2640,2641],{"name":2576,"slug":2577,"type":13},{"name":2579,"slug":2580,"type":13},{"name":15,"slug":16,"type":13},{"name":2583,"slug":2584,"type":13},{"name":9,"slug":8,"type":13},{"slug":4,"name":4,"fn":5,"description":6,"org":2643,"tags":2644,"stars":20,"repoUrl":21,"updatedAt":22},{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[2645,2646,2647],{"name":15,"slug":16,"type":13},{"name":9,"slug":8,"type":13},{"name":18,"slug":19,"type":13},{"slug":2594,"name":2594,"fn":2595,"description":2596,"org":2649,"tags":2650,"stars":20,"repoUrl":21,"updatedAt":2605},{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[2651,2652,2653,2654],{"name":15,"slug":16,"type":13},{"name":9,"slug":8,"type":13},{"name":18,"slug":19,"type":13},{"name":2603,"slug":2604,"type":13},{"slug":2656,"name":2656,"fn":2657,"description":2658,"org":2659,"tags":2660,"stars":20,"repoUrl":21,"updatedAt":2664},"oracle-to-mariadb","migrate Oracle databases to MariaDB","Compatibility guide for developers migrating from Oracle Database to MariaDB. Use when migrating Oracle schemas, PL\u002FSQL procedures, or applications to MariaDB, when Oracle syntax causes unexpected behavior in MariaDB, or when evaluating MariaDB as an Oracle replacement. MariaDB is the only open source database with native PL\u002FSQL compatibility — MariaDB's sql_mode=ORACLE enables migration of approximately 80% of Oracle code without rewrites.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[2661,2662,2663],{"name":15,"slug":16,"type":13},{"name":9,"slug":8,"type":13},{"name":18,"slug":19,"type":13},"2026-07-13T06:14:11.069809"]