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>]
[QUANTIZATION SCALAR COMPRESSION RATIO {2 | 4 | 8}]
[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> },
              RESCORE FACTOR rescore_factor
            )]
[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.
RESCORE FACTOR An optional integer parameter that defines the rescoring multiplier for semantic search queries. It has a default value of 1 and is applied only when the index is quantized (when QUANTIZATION is specified).

The valid range for IVF vector index parameters are:

Parameter Valid Values
ACCURACY > 0 and <= 100
DISTANCE COSINE (default)

EUCLIDEAN

L2_SQUARED (as in EUCLIDEAN_SQUARED)

DOT

MANHATTAN

HAMMING
QUANTIZATION SCALAR
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 ON | OFF. The default value is OFF.
RESCORE FACTOR >= 1 and <= 100 (default 1)

Usage Notes

You can optionally use the QUANTIZATION keyword together with the COMPRESSION RATIO parameter in order to apply scalar quantization to a new vector index.

The COMPRESSION RATIO specifies the level of compression for a vector column when creating a scalar-quantized index. Higher compression ratios yield smaller storage requirements but increased quantization. The possible values for COMPRESSION RATIO are 2, 4, and 8.

The following table shows the resulting data type stored in the index for each compression ratio, depending on the original vector column format.

Compression Ratio FLOAT64 Input FLOAT32 Input
2 FLOAT32 Not Supported
4 Not Supported INT 8
8 INT8 Not Supported

Note that “not supported” means that scalar quantization is not available for the given combination of compression ratio and vector column format.

If the original vector column has a flex format, quantization is only supported when the dimension and type can be resolved to a valid input type from the table data.

Note: Float16 is not currently a valid input format for scalar quantization with IVF indexes.

Examples

For detailed information on the syntax, see CREATE VECTOR INDEX in Oracle AI Database SQL Language Reference.

See Also: