From: beyond-mountains (@beyond-mountains) <noreply+beyond-mountains@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: [pgvector/pgvector] issue #1035: Performance regression: Range-to-OR equivalent filters cause up to 3.600x search latency difference
Date: Tue, 29 Sep 2026 07:51:00 +0000
Message-ID: <gh-pgvector-pgvector-1035@github.com> (raw)
# Performance regression: Range-to-OR equivalent filters cause up to 3.600x search latency difference
## Summary
Equivalent representation: `1≤x≤N ↔ x IN {1,...,N} ↔ x=1 OR x=2 OR ... OR x=N`
Semantically equivalent filters showed a reproduced client end-to-end ANN latency ratio above 2.0x.
Discovery candidates: 9; reproduced configurations: 9.
## Environment
- Backend: PostgreSQL + pgvector
- Database version: PostgreSQL 15.17 (Debian 15.17-1.pgdg12+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14+deb12u1) 12.2.0, 64-bit; pgvector 0.8.2
- Container limit: 8 physical CPU cores, 32 GiB memory
- Dataset: 200000 points, 128 dimensions, correlation=0.85
- HNSW: M=16, efConstruction=128
## Metadata schema and distribution
All listed fields are present and non-null for every pgvector row.
|Field|Type|Domain / generation|
|---|---|---|
|`id`|INT64|Unique sequential ID in `[0, 199999]`|
|`tenant`|INT64|Discrete uniform sample from `[0, 99]`|
|`level`|INT64|Discrete uniform sample from `[0, 31]`|
|`category`|INT64|`tenant + 1`; finite domain `[1, 100]`|
|`category5`|INT64|`tenant % 5 + 1`; finite universe `{1,2,3,4,5}`|
|`age`|INT64|Discrete uniform sample from `[1, 1000]`|
|`parity`|STRING/keyword|`even` when tenant is even, otherwise `odd`|
Vectors are generated around a tenant-specific center with vector/tenant correlation parameter `0.85`; `level` and `age` are sampled independently of tenant. Category, category5, and parity are deterministic functions of tenant.
PostgreSQL B-tree indexes are present on tenant, level, category, category5, age, and parity.
For the strongest case below, the filter selects 60056 / 200000 points (observed selectivity `30.0280%`). The semantic oracle enumerated and directly compared the complete eligible ID sets.
## Strongest reproduced case
- Pattern: Range-to-OR; expression scale=300, K=10, ef_search=16
Original filter:
```sql
age >= 1 AND age <= 300
```
Equivalent filter, abbreviated:
```text
age = 1 OR age = 2 OR ... OR age = 300
```
```python
equivalent_filter = " OR ".join(
f"(age = {value})" for value in range(1, 301)
)
```
- Semantic oracle: equal=True, eligible count=60056
- ANN p50: 0.9765 ms vs 3.5150 ms; symmetric ratio=3.600x; equivalent/original=3.600x
- Exact p50: 107.0102 ms vs 949.2653 ms; ratio=8.871x
- Recall: 0.5100 vs 0.5100; gap=0.0000
- Exact Top-K identical: True