Percona Server for MySQL 9.7 Adds a Native DISTANCE() Function for In-SQL Vector Similarity Search
Percona Server for MySQL 9.7.2-2 ships DISTANCE() and VECTOR_DISTANCE(), letting developers rank embeddings by similarity directly in SQL across five distance metrics.
Overview
Percona Server for MySQL 9.7.2-2 now supports DISTANCE() for vector similarity scoring directly in SQL, covering COSINE, EUCLIDEAN, MANHATTAN, and DOT metrics, according to Percona. The function, written by Percona’s Catalin Besleaga and reviewed by Dennis Kittrell and Peter Zaitsev, lets developers rank or filter rows by vector distance without pulling embeddings out of the database into a separate similarity-search system.
What We Know
- Percona Server for MySQL 9.7.2-2 ships two new SQL functions,
DISTANCE()andVECTOR_DISTANCE(), which Percona describes as an alias with identical behavior, according to Percona. - The release supports five distance metrics: EUCLIDEAN (L2), EUCLIDEAN_SQUARED, MANHATTAN (L1), COSINE similarity, and DOT (inner product), per Percona.
- The functions build on the
VECTORdata type already present in MySQL 9.7, including theTO_VECTOR()andFROM_VECTOR()functions for storing embeddings, according to Percona. Percona framesDISTANCE()as “the natural next step” that lets developers “query by similarity directly in SQL, ranking or filtering rows based on vector distance, without leaving MySQL,” per Percona. - A sample query shared by Percona shows the syntax:
SELECT id, name, DISTANCE(embedding, TO_VECTOR('[0.12, 0.22, 0.32, ..., 0.382]'), 'EUCLIDEAN') AS similarity_score FROM products ORDER BY similarity_score LIMIT 5;, according to Percona. - Percona says the implementation detects CPU capabilities at startup rather than compiling for a single target architecture, selecting from four SIMD tiers: SSE4.2 on x86_64 or NEON on aarch64 (“~2–3× speedup over scalar”), AVX2 on x86_64 (“~4–6× speedup”), AVX-512F on x86_64 (“~8–12× speedup on CPUs that support it”), and SVE2 on aarch64, according to Percona.
- According to Percona, Oracle’s own
DISTANCE()andVECTOR_DISTANCE()functions are “only available in HeatWave MySQL on OCI, not included in Community or Commercial MySQL, and limited to three metrics (COSINE, DOT, EUCLIDEAN)” — a comparison Percona uses to frame its release as bringing “the same capability to anyone running Percona Server for MySQL on any supported platform,” according to Percona. - Percona positions
DISTANCE()as groundwork for approximate-nearest-neighbor indexing methods such as HNSW and IVF, which it calls “the next milestone for fast large-scale similarity search,” with the new function serving as “the scoring primitive that those indexing strategies will accelerate,” per Percona. Percona has not shipped HNSW or IVF indexing as of this release. - The DISTANCE() release follows roughly ten months after Percona first announced plans for native MySQL vector support. In a November 25, 2025 post, Percona’s Dennis Kittrell wrote that the company’s goal was “to deliver a solution that eliminates the complexity, cost, and data consistency headaches of managing a separate, specialized vector database,” with an initial version focused on “native vector search and indexing,” according to Percona.
What We Don’t Know
- Percona’s blog post does not independently benchmark
DISTANCE()against Oracle’s HeatWave implementation or other vector-search systems beyond the SIMD-tier speedup estimates over unaccelerated scalar code. - The post does not specify a release date for HNSW or IVF indexing support, describing them only as a future milestone.
- Percona’s announcement does not state whether
DISTANCE()andVECTOR_DISTANCE()are limited to a specific Percona Server for MySQL edition.
Analysis
The release lands in a crowded field: database vendors from AWS to Weaviate have spent the past year adding native vector-similarity capabilities aimed at retrieval-augmented generation and embedding-search workloads. Percona’s pitch is narrower — it is not proposing a new database, but closing a specific gap in an existing one, arguing that Oracle has confined equivalent DISTANCE() functionality to its HeatWave cloud offering while leaving standalone MySQL users to bolt on separate vector databases. Whether that argument holds up depends on adoption: DISTANCE() alone provides brute-force scoring, not the approximate-nearest-neighbor indexing that makes similarity search practical at large scale, which Percona itself describes as still on the roadmap.