Inverted File Flat CREATE INDEX
Syntax and examples for creating Inverted File Flat vector indexes.
Syntax
CREATE VECTOR INDEX <vector index name>
ON <table name> ( <vector column> )
[GLOBAL] ORGANIZATION [NEIGHBOR] PARTITIONS
[WITH] [DISTANCE <metric name>]
[WITH TARGET ACCURACY <percentage value>
[PARAMETERS ( TYPE IVF,
{ NEIGHBOR PARTITIONS <number of partitions> |
SAMPLES_PER_PARTITION <number of samples> |
MIN_VECTORS_PER_PARTITION <minimum number of vectors per partition> |
NEIGHBOR PARTITION GROUPING <ON | OFF> }
)]]
[PARALLEL <degree of parallelism>]
[LOCAL];The GLOBAL clause specifies a global IVF index. By default, IVF vector indexes are globally partitioned by centroid.
Specify the LOCAL clause to create a local IVF index.
IVF PARAMETERS
| Parameter | Purpose |
|---|---|
NEIGHBOR PARTITIONS |
Determines the target number of centroid partitions that are created by the index. |
SAMPLES_PER_PARTITION |
Decides the total number of vectors that are passed
to the clustering algorithm ( |
MIN_VECTORS_PER_PARTITION |
Represents the target minimum number of vectors per partition. The goal is to trim out any partition that can end up with few vectors (<= 100). |
NEIGHBOR PARTITION GROUPING |
Enables, in addition to partitioning, further data grouping in the storage layer for centroids in the IVF index. This can result in query performance benefits in serial, parallel, and multi-user (concurrent) queries due to additional pruning during the scan. When this storage optimization is enabled, the default number of centroids may increase, which can lead to a longer IVF index creation time. To disable this feature, you must drop the index and recreate it. Neighbor partition grouping will continue to be enabled on an index that is rebuilt. Online index rebuild is supported on IVF indexes that have this storage option enabled. Neighbor partition grouping can only be specified upon index
creation and cannot be enabled or disabled using This parameter is only applicable to global IVF indexes. It is not supported with HNSW indexes or local IVF indexes. |
The valid range for IVF vector index parameters are:
ACCURACY |
> 0 and <= 100 |
DISTANCE |
|
TYPE |
IVF |
NEIGHBOR PARTITIONS |
>0 and <= 10000000 |
SAMPLES_PER_PARTITION |
From 1 to
(num_vectors/neighbor_partitions)
|
MIN_VECTORS_PER_PARTITION |
From 0 (no trimming of centroid partitions) to total number of vectors (which would result in 1 centroid partition) |
NEIGHBOR PARTITION GROUPING |
|
Examples
-
To create a global IVF index:
CREATE VECTOR INDEX galaxies_ivf_idx ON galaxies (embedding) ORGANIZATION NEIGHBOR PARTITIONS DISTANCE COSINE WITH TARGET ACCURACY 95;CREATE VECTOR INDEX galaxies_ivf_idx ON galaxies (embedding) ORGANIZATION NEIGHBOR PARTITIONS DISTANCE COSINE WITH TARGET ACCURACY 90 PARAMETERS ( TYPE IVF, NEIGHBOR PARTITIONS 10 );CREATE VECTOR INDEX galaxies_ivf_idx ON galaxies (embedding) ORGANIZATION NEIGHBOR PARTITIONS DISTANCE EUCLIDEAN WITH TARGET ACCURACY 95 PARAMETERS ( TYPE IVF, NEIGHBOR PARTITIONS 100, NEIGHBOR PARTITION GROUPING ON ) TABLESPACE my_tablespace; -
To create a local IVF index:
CREATE VECTOR INDEX galaxies_ivf_idx ON galaxies (embedding) ORGANIZATION NEIGHBOR PARTITIONS DISTANCE COSINE WITH TARGET ACCURACY 90 PARAMETERS ( TYPE IVF, NEIGHBOR PARTITIONS 10 ) LOCAL;
For detailed information on the syntax, see CREATE VECTOR INDEX in Oracle AI Database SQL Language Reference.
- Create IVF Index Online
When the base table must remain available for ongoing updates and cannot be locked during index creation, use theONLINEclause withCREATE VECTOR INDEXto build the IVF index online. This allows applications with heavy DML to continue updating the table while the index is being created.
Related Topics
Parent topic: Neighbor Partition Vector Index