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 (samples_per_partition * neighbor_partitions). Passing all the vectors could significantly increase the total index creation time. The goal is to pass in a subset of vectors that can capture the data distribution.

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 ALTER INDEX or REBUILD.

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:

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.