Choosing the Right JSON Index

Choose a JSON index that matches the query pattern and the behavior of the indexed field.

Oracle provides several JSON index types. Start by identifying the query pattern—targeted lookup or ad hoc search—and the field’s cardinality—single value or multiple values per document. That combination determines the best index.

Index Selection Guidelines

Use these guidelines:

Performance Comparison

JSON value indexes, JSON search indexes, and vector indexes use different index structures and are suited to different query patterns.

Index type Index structure Best suited for DML cost
Value indexes (single-value and multivalue JSON indexes) B-tree Targeted retrieval using known JSON paths Typically lower
JSON search indexes Posting lists Broader structural queries, ad hoc search, and full-text search Typically higher
Function-based vector indexes HNSW vector index Vector similarity search over embeddings stored in JSON Additional index-maintenance cost; online index creation required

JSON Index Selection Decision Tree

The image is a decision-tree diagram for choosing a JSON index type.

The decision tree covers JSON value indexes and JSON search indexes. For similarity search over vector embeddings stored in JSON, use a function-based HNSW vector index.

Given the sample data:

If the data is stored in a JSON collection table, the _id field ($._id) is indexed by default with a unique index. No additional index is required for lookups by document ID.