Skip to content

本页尚未翻译

本页内容仍为英文原文,源自官方文档 sql/dql/ivf-partition。中文翻译正在分批进行中。

IVF_PARTITION ​

The ivf_partition() scalar function: assign each row to its trained IVF index partition.

Applies to: Embedded ❌, Enterprise ✅

sql
SELECT
    ivf_partition(embedding, selection => 'random', count => 100, seed => 42) AS partition,
    array_agg(id) AS ids
FROM documents
GROUP BY partition

ivf_partition reads an existing IVF-family vector index's trained partitions and assigns each row to the one its vector falls into. The column needs an up-to-date, single-segment index before the function runs -- the same requirement dedupe has.

Grouping by its result buckets rows by vector proximity without a full pairwise scan -- useful for blocking a large table into comparable chunks, such as before a pairwise similarity pass.

Input ​

ivf_partition takes exactly 1, 3, or 4 arguments -- the vector column alone (scans every partition), or the vector column plus selection and count, plus seed only when selection is 'random':

ArgumentTypeRequiredMeaning
vector columncolumn referenceyesthe indexed vector column to assign
selection'first' | 'random'required with countwhich partitions to sample -- there is no explicit 'all'; omit selection and count entirely to scan every partition
countint, > 0required with selectionnumber of partitions to sample
seedint, >= 0required for 'random', refused for 'first'random seed

Arguments can be passed positionally, ivf_partition(embedding, 'random', 100, 42), or named as shown above. count and seed are the same scan-scoping arguments duplicate_pairs accepts, so a sampled partition estimate carries over -- but not dedupe, which always scans every partition and refuses sampling arguments entirely.

Cluster records by index partitionUse this function to group and sample records by an existing index's partitions.DEDUPEThe packaged table function for the deduplication use case, over the same index.