We’ve now published three blog posts describing the different indexes available in AI Vector Search (Using HNSW Vector Indexes, IVF Indexes, and Hybrid Vector Indexes). This post provides guidelines on when to use these different indexes.
To review, if you don’t have a vector index defined, or your query doesn’t use a vector index, the similarity search performed will be an exhaustive search. In other words, the database will examine every vector in the vector column and compare the distance to the search vector. This will appear in an execution plan as a full table scan, and while accurate, it can be slow and consume a significant amount of computing resources. If your query uses a vector index, you will get an approximate similarity search. In most cases, the query will run much faster, but it may not be as accurate as an exhaustive similarity search. This is different than how a relational index search works, but in almost all cases, it is accurate enough to provide good results. This is discussed in more detail in the Using HNSW Vector Indexes post.
The following will briefly review each of the three vector index types and why you might choose each type of index.
HNSW Indexes
For the best performance, you should consider using an HNSW vector index. Since it is an in-memory only index, you will need to have enough memory to load the entire index into memory. Another consideration is that for RAC, each RAC node will have its own copy of the HNSW index.
IVF Indexes
If your vector index is too large to fit into memory, then you can use an IVF index. An IVF index utilizes a small amount of memory in the Vector Pool; however, since it is a storage-based index, it can scale to be much larger than an HNSW vector index while still providing excellent query performance.
IVF vector indexes can also be globally or locally partitioned, which can help with manageability and improve query performance.
Hybrid Vector Indexes
A hybrid vector index combines the benefits of similarity search using AI Vector Search with keyword search using an Oracle Text domain index. You should consider using a hybrid vector index when you have similarity searches that can be enhanced with a keyword search. A hybrid vector index is made up of both an Oracle Text domain index and an AI Vector Search vector index, and the vector index can be either an HSNW vector index or an IVF vector index.
As described in the Using Hybrid Vector Indexes blog post, an additional benefit of creating a hybrid vector index is that it automatically performs chunking and vector embedding as part of the index creation. If you are not familiar with the term “chunking”, it is a process performed on large textual data to split it into smaller “chunks”. This can enhance the relevance of the text being vectorized and can avoid any size limits imposed by embedding model limits.
You can also perform pure semantic mode queries with a hybrid vector index to perform a vector-only search. The takeaway is that a hybrid vector index can be an easier way to create a vector index.
Wrap Up
Generally, creating vector indexes is recommended to optimize similarity search query performance. This will allow your data to grow without sacrificing performance. Depending on how big your vectors become, you should consider HNSW vector indexes first and IVF vector indexes if you know your vector indexes will be larger than the memory you can allocate. And yes, you can have both, just not on the same column. In addition, if you have similarity searches that can be enhanced with keyword searches then you should consider Hybrid Vector Indexes and choose the type of vector index, that is HNSW or IVF, using the criteria outlined above.
