Cert EspressoLearn. Practise. Find your flow.

A LITTLE FOCUS.
A BIG NEXT STEP.

Your pace. Your space.
Oracle · Agentic AI for Oracle AI Database Professional

Approximate Search and Accuracy

Agentic AI for Oracle AI Database Professional · Lesson 8 of 20 · 53:36

YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗

Learning with these videos? Subscribe for new courses and exam-style questions.

In this lesson

Prepare for the Agentic AI for Oracle AI Database Professional exam (1Z0-1159-26). In this lesson: FETCH APPROX with a target accuracy, when the optimizer uses the vector index, index hints, and measuring accuracy with INDEX_ACCURACY_QUERY and INDEX_ACCURACY_REPORT. Follows Ambergate Appliances, a fictional appliance maker. Includes three original practice questions.

Study notes

The text of this lesson, to read at your own pace. Information as of November 2026.

How accurate is fast?

Ambergate's repair assistant now answers in milliseconds, thanks to its vector index. But the quality team wants proof that the answers are still accurate, and a few queries seem to ignore the index entirely. This lesson covers approximate search, the query, when the optimizer uses the index, and how to measure accuracy.

Approximate search

An approximate search uses a vector index, and trades a little accuracy for a lot of speed. Its algorithms are heuristic, so accuracy is not guaranteed, and a search can even return fewer rows than requested. Accuracy is the share of the true nearest neighbors that the search finds. If an exact search returns five rows and the approximate search finds four of them, its accuracy is eighty percent.

The query

The query writes fetch approx first, with the number of rows to keep. With target accuracy sets the accuracy for this query, and it overrides the value given when the index was created. Instead of a percentage, a query can also set a parameter directly: EFSEARCH for an HNSW index, or neighbor partition probes for an IVF index. Higher values look at more vectors, so they give better accuracy and slower searches.

When the index is used

Writing approx does not force the index: the optimizer uses it only under some conditions. The metric in the query must match the metric of the index, and an index created without one uses cosine. VECTOR_DISTANCE must not be wrapped inside another function, like a rounding function. Otherwise, the database quietly runs an exact search, which is correct, but slow.

Filters and hints

With a where clause, the optimizer picks a filter type: a pre-filter applies the filter before the vector search, an in-filter applies it during an HNSW search, and a post-filter applies it afterwards. Hints can steer the plan: VECTOR_INDEX_SCAN asks to search an HNSW index directly, and VECTOR_INDEX_TRANSFORM asks for an index plan, with a filter type. NO_VECTOR_INDEX_SCAN and NO_VECTOR_INDEX_TRANSFORM do the opposite. A hint can still be ignored, so when a search must not use the index, write fetch exact.

Measuring accuracy

To check one search, DBMS_VECTOR.INDEX_ACCURACY_QUERY takes a query vector, the number of neighbors, and a target accuracy, and compares the index search with an exact one. For real traffic, the database captures the vectors of approximate queries, and this capture is on by default. INDEX_ACCURACY_REPORT then checks the captured queries, from the last twenty four hours by default. Its results appear in the DBA_VECTOR_INDEX_ACCURACY_REPORT view, grouped in bands of target accuracy.

Recap

Let's recap. An approximate search uses an index, trades a little accuracy for speed, and accuracy is the share of true neighbors found. Fetch approx first, with target accuracy, sets the accuracy for one query, or EFSEARCH and probes set the search directly. The index is used only with the same metric and an unwrapped VECTOR_DISTANCE, and otherwise the search is exact. Filter types and hints steer the plan, and fetch exact is the only sure way to skip the index. And INDEX_ACCURACY_QUERY checks one vector, while INDEX_ACCURACY_REPORT checks captured real queries.

Quick checks for this lesson

The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.

  1. Ambergate created its vector index with a target accuracy of 80%. One safety query now needs 95%, while every other query should stay as fast as it is. What should the team do?

    • Drop and recreate the index at 95%
    • Give the vector pool more memory
    • Write FETCH FIRST without the APPROX keyword
    • Add a target accuracy of 95 to that query
    Show the answer

    Add a target accuracy of 95 to that query

    A target accuracy in the query overrides the index value, for that query only. “Drop and recreate the index at 95%” would raise the accuracy of every query, and slow them all down. “Give the vector pool more memory” is about memory, and it does not set the accuracy of a search. And “Write FETCH FIRST without the APPROX keyword” only removes a keyword, so the search is still approximate.

  2. A developer orders the rows by ROUND(VECTOR_DISTANCE(...), 3), with FETCH APPROX FIRST 10 ROWS ONLY. The index uses the same metric, yet the plan shows no vector index. Why?

    • VECTOR_DISTANCE is wrapped in a function
    • The query sets no target accuracy of its own
    • The vector pool is too small for an APPROX search
    • The query has no VECTOR_INDEX_SCAN hint in it
    Show the answer

    VECTOR_DISTANCE is wrapped in a function

    Once VECTOR_DISTANCE is wrapped inside another function, the optimizer cannot use the vector index, so the search becomes exact. “The query sets no target accuracy of its own” is wrong, because a query without a target accuracy simply uses the value of the index. “The vector pool is too small for an APPROX search” would have stopped the index from being created in the first place. And “The query has no VECTOR_INDEX_SCAN hint in it” is wrong, since no hint is needed for the index to be used.

  3. Ambergate’s quality team wants to know how accurate the index was on the questions that technicians actually asked yesterday. Which tool fits?

    • INDEX_ACCURACY_QUERY on one chosen vector
    • The V$VECTOR_MEMORY_POOL view
    • INDEX_ACCURACY_REPORT on captured queries
    • A VECTOR_INDEX_TRANSFORM hint on each query
    Show the answer

    INDEX_ACCURACY_REPORT on captured queries

    The accuracy report checks the query vectors captured from real traffic, by default over the last day. “INDEX_ACCURACY_QUERY on one chosen vector” checks only one chosen vector at a time. “The V$VECTOR_MEMORY_POOL view” shows how much memory the indexes use, not how accurate they are. And “A VECTOR_INDEX_TRANSFORM hint on each query” is about plans, and it does not measure accuracy.