RoanHeNaN opened a new issue, #71313:
URL: https://github.com/apache/doris/issues/71313

   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no 
similar issues.
   
   ### Description
   
   IVF / IVF_ON_DISK ANN indexes take a single table-level `nlist`, but the 
index is built **per segment**, and segment sizes vary by orders of magnitude 
(a fresh load writes small segments; compaction produces large ones). A fixed 
`nlist` therefore gives:
   
   - **Small segments**: almost empty lists. With `nlist=1024`, a 3,125-row 
segment has ~3 vectors per list. Each segment still stores and scans 1024 
float32 centroids (8 MB at dim 2048), so the centroids are larger than the 
codes. Measured on 1,600 such segments (5M x 2048-d, sq8): the index is 23.8 GB 
instead of 10.6 GB, and the first query after a BE restart takes 114 s because 
13 GB of centroids must be loaded.
   - **Large segments**: lists that are too large, with no way to tune it per 
segment.
   - **A query-side mismatch**: `ivf_nprobe` is an absolute count, so the same 
value probes a different fraction of each segment (`nprobe=32` is everything in 
a segment with `nlist=32`, and 3% of one with `nlist=1024`).
   
   ### Proposal
   
   Follow the approach of Elasticsearch DiskBBQ (`cluster_size`, 
`visit_percentage`):
   
   1. A new IVF index property **`ivf_cluster_rows`**, the target number of 
vectors per list. Each segment uses `nlist = round(rows / ivf_cluster_rows)`, 
clamped to [1, 65536]. It is mutually exclusive with `nlist`. When neither is 
given, FE persists the default `ivf_cluster_rows = 384`, so the stored metadata 
states it and a BE upgrade cannot change it. Existing indexes that set `nlist` 
keep their behavior.
   2. A new session variable **`ivf_nprobe_ratio`** in [0, 1]. When it is > 0, 
each segment probes `ceil(ratio * nlist of that segment)` lists, clamped to [1, 
nlist]. The default 0 keeps using `ivf_nprobe`. The ANN result cache key 
includes the ratio.
   
   ### Use case
   
   Vector tables where segments of very different sizes coexist (continuous 
loads plus compaction), especially `ivf_on_disk`, where every list is one read 
and one list-cache entry and the centroids are always resident.
   
   ### Related issues
   
   None found.
   
   ### Are you willing to submit PR?
   
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to