Skip to content

[Bug]: big table join with small inline table on pks has no runtime filter. #22653

Closed

Description

@gouhongshen

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main, 3.0-dev

Commit ID

latest

Other Environment Information

- Hardware parameters:
- OS type:
- Others:

Actual Behavior

drop database if exists test;
create database test
use test;

create table t0(a int, b int, c int, primary key(a, b));
insert into t0 select *,*,* from generate_series(1, 1000*1000*10)g;

select t0.* from t0 join (values row(1,1),row(2,2),row(3,3)) as pks(a,b) on t0.a=pks.a and t0.b=pks.b;

plan:

explain analyze select t0.* from t0 join (values row(1,1),row(2,2),row(3,3)) as pks(a,b) on t0.a=pks.a and t0.b=pks.b;
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ap query plan on multicn(12 core)                                                                                                                                                                                                                                                            |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Project                                                                                                                                                                                                                                                                                      |
|   Analyze: timeConsumed=1ms waitTime=354ms inputRows=3 outputRows=3 (min=3, max=3) InputSize=36 bytes OutputSize=36 bytes MemorySize=36 bytes (min=0 bytes, max=36 bytes)                                                                                                                    |
|   ->  Join                                                                                                                                                                                                                                                                                   |
|         Analyze: timeConsumed=243ms probe_time=[total=243ms,min=16ms,max=31ms,dop=12] build_time=[0ms] waitTime=0ms inputRows=10000003 outputRows=3 (min=0, max=3) InputSize=114.44 MiB OutputSize=36 bytes MemorySize=833.77 KiB (min=64.13 KiB, max=64.18 KiB)                             |
|         Join Type: INNER                                                                                                                                                                                                                                                                     |
|         Join Cond: (cast(t0.a AS BIGINT) = pks.a), (cast(t0.b AS BIGINT) = pks.b)                                                                                                                                                                                                            |
|         ->  Table Scan on test.t0                                                                                                                                                                                                                                                            |
|               Analyze: timeConsumed=3220ms scan_time=[total=3220ms,min=160ms,max=335ms,dop=12] waitTime=0ms inputBlocks=1221 inputRows=10000000 outputRows=10000000 (min=824960, max=835584) InputSize=114.44 MiB OutputSize=114.44 MiB MemorySize=2.25 MiB (min=192.00 KiB, max=192.00 KiB) |
|         ->  Project                                                                                                                                                                                                                                                                          |
|               Analyze: timeConsumed=0ms waitTime=0ms inputRows=3 outputRows=3 (min=3, max=3) InputSize=48 bytes OutputSize=48 bytes MemorySize=48 bytes (min=48 bytes, max=48 bytes)                                                                                                         |
|               ->  Values Scan "*VALUES*"                                                                                                                                                                                                                                                     |
|                     Analyze: timeConsumed=0ms waitTime=0ms inputRows=3 outputRows=3 (min=3, max=3) InputSize=48 bytes OutputSize=48 bytes MemorySize=0 bytes (min=0 bytes, max=0 bytes)                                                                                                      |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
12 rows in set (0.36 sec)

Expected Behavior

No response

Steps to Reproduce

see Actual Behavior

Additional information

No response

Activity

  1. added
    kind/bug
    on Oct 22, 2025
  2. added
    severity/s1
    on Jul 1, 2026
  3. assigned and unassigned on Jul 1, 2026
  4. added and removed
    severity/s1
    on Jul 6, 2026
  5. added theissue type on Jul 6, 2026
  6. added this to the MO-202607 milestone on Jul 6, 2026
  7. added
    severity/s0
    and removed on Aug 25, 2026
  8. Ariznawlll commented on Aug 25, 2026

    @Ariznawlll
    Collaborator

    测试版本

    • 分支:`main`
    • commit:`ae12701a888fac102e9641cc7cbb8706527366d8`
    • 部署方式:本地 1CN/1TN/1Log,MySQL 协议
    • 测试日期:2026-08-25

    原问题验证

    构造 100 万行复合主键表并与小型 inline 表按完整主键连接。连续 3 个独立轮次中,结果与精确主键集合一致;`EXPLAIN ANALYZE` 均显示 Runtime Filter Build,并在 `t0.__mo_cpkey_col` 上 Probe。

    Happy Path 覆盖

    1. 3 个命中复合主键的连接精确返回对应 3 行。
    2. 计划包含 `Runtime Filter Build` 和 `Runtime Filter Probe`,Probe 键为复合主键列。
    3. 100 万行基表下分析结果仅扫描 2 个 block / 3 行,未退化为全表探测。

    Unhappy Path 覆盖

    1. inline 表给出不存在的复合主键时结果为 `0` 行,执行和计划均正常完成。

    白盒验证

    已在 `pkg/sql/plan` 连续 3 轮执行 `TestGenerateRuntimeFilters`、`TestAnalyzeRuntimeFilterJoinPolicy`、`TestForceJoinOnOneCNRuntimeFilterPolicy`,均通过,覆盖 planner 的 Runtime Filter 生成和 join policy。

    回归测试

    回归位于 MatrixOne planner 单元测试 `pkg/sql/plan`;此问题的关键是优化器决策,白盒计划用例比固化物理计划的 motr 更稳定。100 万行实测已覆盖规模门槛,不需要额外大数据量测试。

    测试证据

    • latest main 的 100 万行黑盒场景 `3/3` 通过。
    • pkg/sql/plan focused UT `3/3` 通过。

    测试结论

    测试通过。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions