My vector search query in PolarDB is performing a full table scan, and it's becoming unacceptably slow as my dataset grows to over 1 million records. The query calculates L2 distance between a user's input vector and stored vectors.
The query looks something like this:
SET @query_vector = '[...a long array of floats...]';
SELECT
id,
DISTANCE(t.embedding, STRING_TO_VECTOR(@query_vector), 'EUCLIDEAN') as l2_distance
FROM
items t
GROUP BY
t.id
ORDER BY
l2_distance ASC
LIMIT 10;
This is obviously very slow. I know that traditional B-Tree indexes are not effective for high-dimensional vector data.
Are there any native indexing strategies in the PolarDB for accelerating Approximate Nearest Neighbor (ANN) search, similar to HNSW or IVF indexes found in dedicated vector databases? If not, what are the most common and effective workarounds for creating a performant index-like structure for vector search within standard PolarDB?