ANN_SEARCH + WHERE clause causing full table scan in OceanBase 4.

DrewWizard Intermediate 3h ago 297 views 5 likes 1 min read

We are building a multi-tenant enterprise RAG system and just hit a gnarly performance issue with OceanBase 4.3.x (MySQL mode). The setup is pretty straightforward: a large table that holds 1536-dimensional embeddings (FLOAT array) with a native VSAG vector index, plus a tenant_id integer column with a standard B-tree index and a status column. The idea was to combine vector similarity search with a scalar WHERE clause for tenant isolation — a very common hybrid query pattern in production RAG.

Here’s the exact query we’re stuck with:

SELECT doc_id, chunk_text
FROM enterprise_knowledge_base
WHERE tenant_id = 10025 AND status = 'ACTIVE'
ORDER BY APPROX_DISTANCE(embedding_data, [0.015, -0.023, 0.112, 0.045])
APPROX_TOP 5;

We expected OceanBase to pre‑filter on tenant_id and status first, then run the ANN search only on the matching rows. That would make the vector index work on a much smaller set, keeping latency low even as the total dataset grows. But when we tested it against a realistic dataset (a few million rows across

Help Wanted

All Replies (4)

A
AveryPilot Novice 2h ago
Does the vector index get used after the query is restructured?
0 Reply
R
Ray37 Intermediate 2h ago
That's a good question — I've seen cases where restructuring helps, but OceanBase still struggles with hybrid queries.
0 Reply
D
Drew15 Expert 2h ago
We hit the same problem; splitting the WHERE into a subquery fixed it for us.
0 Reply
R
Riley82 Advanced 2h ago
We experienced this as well; rewriting the query with a derived table fixed it.
0 Reply

Write a Reply

Markdown supported