Files
lancedb/docs/web/sql/dql/duplicate-pairs.mdx
T
Jack YeandClaude Sonnet 5 de95ed3f6d docs: overhaul curation, feature engineering, security and deployment guides (#4748)
A broad documentation pass across the areas LanceDB Enterprise and
Embedded
diverge on most:

**Data Curation** -- GPU Function execution, Slurm scheduling (and what
Slurm is, for readers new to it), blob late materialization as its own
page, joins, aggregation/profiling, sampling, near-duplicate detection,
chunking, distributed shuffle, and IVF-partition clustering.

**Feature Engineering** -- computed columns and materialized views,
restructured to lead with the Function-based path and show the SQL form
side by side with Python throughout; a single Auto Refresh page instead
of
duplicating scheduling details on every refresh page; adaptive
execution;
checkpointing; GPU and Slurm placement for refresh workers; a Training
Cache page for the PyTorch data loader's automatic cache benefit.

**Security & Governance** -- an Audit Log reference (schema, access,
grants), Secrets promoted to an ordinary catalog object with their own
SQL
DDL and a vending/rotation guide, and privilege-table fixes verified
against the authorization source.

**Deployment & Maintenance** -- Horizontal Scaling and OpenTelemetry
moved
into a real Deployment area; Automated Cleanup folded into Intelligent
Auto-Maintenance (every other maintenance decision already lived there);
RTE Compaction and Advanced Conflict Resolution documented in depth.

**Landing page** -- the Enterprise feature comparison table reorganized
(several redundant or stale rows removed, several new areas added), and
the
"why Enterprise" bullets replaced with ones tied to a concrete page
(Performance, Scale, Fault tolerance, Multicloud deployment, Simplify
operations) instead of vague promises.

Plus a full pass addressing lancedb-gatekeeper's review: a real
test-safety
bug (a quickstart test could silently overwrite and delete a
deployment's
own `frames` table), a fabricated SQL statement with no backing
implementation, an actual dedup-guarantee bug in `take_row_ids`, and
dozens
of documentation-accuracy fixes verified against source rather than
taken
on faith -- each either fixed, or left with an explicit note on why it
needs a feature or deployment owner's sign-off instead of being guessed
at.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_018PXMCbRH6i5w47TsjeEUMT

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-11-03 16:17:24 -08:00

124 lines
4.2 KiB
Plaintext

---
title: "DUPLICATE_PAIRS"
sidebarTitle: "DUPLICATE_PAIRS"
description: "The duplicate_pairs() table function: every close pair in a vector column, scanned over the index."
icon: clone
keywords: ["duplicate_pairs", "vector_duplicate_pairs", "sql", "deduplication", "near-duplicate", "table function"]
availability:
embedded: unavailable
enterprise: available
---
`duplicate_pairs` scans a vector column's [index](/indexing/vector-index)
partitions for every pair of rows closer than a distance threshold, without a
full pairwise scan or a shuffle. It returns one row per close pair, not one
row per source row -- use it to inspect what would be collapsed before
committing to [`dedupe`](/sql/dql/dedupe), which resolves these same pairs
into groups.
<CodeGroup>
```sql SQL icon="database"
SELECT * FROM duplicate_pairs(
<table>,
<vector_column>,
distance_threshold => <float>
[, id_column => <column>]
[, selection => 'all' | 'first' | 'random', count => <int>, seed => <int>]
)
```
</CodeGroup>
<CodeGroup>
```sql SQL icon="database"
SELECT * FROM duplicate_pairs(
'frames',
'vec',
distance_threshold => 0.02
)
```
</CodeGroup>
<Note>
Earlier releases spelled this `vector_duplicate_pairs`; that name is rejected
on current deployments.
</Note>
## Input {#input}
| Argument | Type | Required | Meaning |
| --- | --- | --- | --- |
| table name | string literal | yes | the table to scan |
| vector column | string literal | yes | the indexed vector column to compare |
| `distance_threshold` | float | yes | maximum distance for a pair to count as close |
| `id_column` | column name | no | project this column's value instead of the internal row ID -- see [Application-level identifiers](#id-column) |
| `selection` | `'all'` (default) \| `'first'` \| `'random'` | no | which index partitions to scan |
| `count` | int | no | number of partitions to sample when `selection => 'random'` |
| `seed` | int | no | random seed when `selection => 'random'` |
`resolution` is refused on `duplicate_pairs`: a pair has no notion of a group,
only [`dedupe`](/sql/dql/dedupe#input) accepts it.
## Output {#output}
One row per close pair found, in a fixed schema independent of the source
table:
| Column | Type | Meaning |
| --- | --- | --- |
| `row_id_a` | uint64 | internal row ID of the first row in the pair, the same identifier as the [`_rowid`](/sql/data-types#pseudo-columns) pseudo-column |
| `row_id_b` | uint64 | internal row ID of the second row in the pair |
| `distance` | float32 | distance between the pair's vectors, at or below `distance_threshold`. For `l2`, this is the squared distance, not its square root |
| `segment_id` | Utf8 | which index segment the pair was found in, a UUID |
| `partition_id` | uint64 | which index partition the pair was found in |
| `dataset_version` | uint64 | the dataset version the scan ran against |
### Application-level identifiers {#id-column}
A row ID is internal and not stable across compaction. Pass `id_column`, a
top-level scalar column such as a primary key, to also project its value:
`id_a`/`id_b`, typed like `id_column`, are appended alongside
`row_id_a`/`row_id_b`, which remain in the output.
<CodeGroup>
```sql SQL icon="database"
SELECT * FROM duplicate_pairs(
'frames',
'vec',
distance_threshold => 0.02,
id_column => 'frame_id'
)
```
</CodeGroup>
## Sampling partitions {#sampling}
`selection` scopes the scan to a sample of partitions instead of all of them,
the same `all` (default) / `first` / `random` choice as
[`ivf_partition`](/sql/dql/ivf-partition). Use it to estimate a
distance threshold or duplicate rate on a large table before scanning it in
full:
<CodeGroup>
```sql SQL icon="database"
SELECT * FROM duplicate_pairs(
'frames',
'vec',
distance_threshold => 0.02,
selection => 'random',
count => 100,
seed => 42
)
```
</CodeGroup>
## What to read next {#next}
<CardGroup cols={2}>
<Card title="DEDUPE" icon="layer-group" href="/sql/dql/dedupe">
Resolve these same pairs into one representative row per group.
</Card>
<Card title="Deduplicate near-duplicates" icon="copy" href="/curation/dedupe">
When to reach for this instead of exact-key deduplication.
</Card>
</CardGroup>