Repository navigation
Description
MatrixOne version
01d60e1c4ded1b0f3fc1a4ecd75ce54e95e23b90 (current main under validation)
Environment
Local distributed deployment with 2 CN, 1 TN, and 1 log service.
Problem
LIMIT ... BY RANK WITH OPTION accepts the documented/proposed query-level nprobe and fudge_factor options, but the planner silently discards both. Only mode is copied into plan.RankOption.
Consequently, users cannot tune IVF probe count per query even though the SQL is accepted. The actual NProbe always comes from the session variable probe_limit.
Reproduction
set experimental_ivf_index = 1;
create database rank_option_repro;
use rank_option_repro;
create table t(id bigint primary key, v vecf32(2));
insert into t select result, concat('[', result, ',', result, ']')
from generate_series(1, 1000) g;
create index ix using ivfflat on t(v)
op_type 'vector_l2_ops' lists=20;
set probe_limit = 5;
explain verbose
select id from t
order by l2_distance(v, '[0,0]')
limit 5 by rank with option 'mode=post', 'nprobe=1';
explain verbose
select id from t
order by l2_distance(v, '[0,0]')
limit 5 by rank with option 'mode=post', 'nprobe=99';
explain verbose
select id from t
order by l2_distance(v, '[0,0]')
limit 5 by rank with option 'mode=post', 'fudge_factor=100';All three plans report:
Vector Index: ix, Metric: l2_distance, Candidate Limit: 5, NProbe: 5
Changing only the session variable proves which value is used:
set probe_limit = 1;
explain verbose
select id from t
order by l2_distance(v, '[0,0]')
limit 5 by rank with option 'mode=post', 'nprobe=99';
-- NProbe: 1
set probe_limit = 17;
explain verbose
select id from t
order by l2_distance(v, '[0,0]')
limit 5 by rank with option 'mode=post', 'nprobe=1';
-- NProbe: 17The behavior is identical on both CNs and is deterministic across repeated planning.
Code path
The parser stores every option in tree.RankOption.Option, but parseRankOption in pkg/sql/plan/query_builder.go extracts only mode and returns a protobuf RankOption containing only that field. prepareIvfIndexContext then resolves NProbe exclusively from probe_limit.
The original LIMIT BY RANK request (#22919) explicitly proposed fudge_factor and nprobe as query-level controls and was closed as supported. Current parser tests also accept these option names, so silently ignoring them is misleading.
Expected behavior
Either:
- apply supported query-level
nprobe/fudge_factorvalues to the vector search plan with validation and documented precedence over session defaults; or - reject unsupported rank options explicitly instead of accepting and discarding them.
Unknown option names should likewise not be silently treated as effective settings.
Impact
Per-query IVF recall/latency tuning does not work. Operators may believe a query uses a larger probe budget while it continues to run with the session default, which can produce unexpected recall and latency characteristics.
Activity
Ariznawlll commentedon Sep 16, 2026
补充 unhappy-case 证据:option 不仅不生效,也完全不校验。以下三条都被接受并生成相同计划(session
probe_limit=5,计划均为NProbe: 5):因此用户写错 key、写入非法值或以为在逐查询调参时都得不到任何提示。建议支持的 option 做类型/范围校验,未知 key 直接报错;不要继续静默回落到 session 默认。
Ariznawlll commentedon Sep 16, 2026
补充算法范围:该问题不只影响 CPU
IVFFLAT,同一条 query-levelnprobe选项在 GPUIVF-PQ规划路径中也不会生效。代码路径如下:
parseRankOption仍只把mode写入plan.RankOption,nprobe在这里已丢失;prepareIvfpqIndexContext随后只通过ResolveVariable("probe_limit", ...)获取nProbe;ivfpq_search配置中的"nprobe"直接使用这个 session 值,不存在 query option 覆盖路径。因此 #28996 的修复范围需要同时包含
IVFFLAT和IVF-PQ。CAGRA本身没有nprobe参数,不属于这部分。本次在 commit
01d60e1c4ded1b0f3fc1a4ecd75ce54e95e23b90上完成规划器代码核查,并运行pkg/sql/plan中 IVF-PQ/CAGRA 的 force、success、rich-pushdown 针对性 UT;本地 CPU 部署不具备 GPU IVF-PQ 执行条件,因此这里没有把白盒结论写成 GPU 运行结果。Ariznawlll commentedon Oct 29, 2026
结论
测试通过。本次按已确认的单 CN 验收范围,查询级 nprobe 生效,非法或不支持的选项被拒绝。
关键证据
main@1cea057047b7485736421842612c38d5667152ef的 GPU 镜像,单 CN、单 NVIDIA RTX 4090;镜像 digest 为sha256:5e83d01ed5605d6a0ef369bcc3a79344ebce40e42d616930fa87ce699f159dcc。该版本不是本评论发布时最新 main。probe_limit=5时,查询选项nprobe=1、99的 EXPLAIN 分别显示 1、99,而非静默回落 5;正常查询结果正确。切换 session 值、prepared 重用、非法范围、非数字、未知 key 和不支持的fudge_factor进行校验,拒绝后源行和元数据保持不变。待解决点