Skip to content

[Tech Request]: optmize duplicate check memory usage for sql like insert into t1 selct from t2 #16375

Closed

Description

@jensenojs

Is there an existing issue for the same tech request?

  • I have checked the existing issues.

Does this tech request not affect user experience?

  • This tech request doesn't affect user experience.

What would you like to be added ?

insert into t1 select * from t2

对于通过sql的方式复制一张表, 在表规模上到十几亿或者几十亿的时候, fuzzy占用的内存会比较大. 估算十亿的时候占用5GB, 七十亿的时候要三四十GB.

目前有一部份原因是会把sink scan的数据通过test and add的方式导入布隆过滤器, 如果sink scan的数据很大, , 那么申请出来的布隆过滤器也会很大.

但实际上

  • 如果t1和t2的表结构一样(或者说有能对应上的唯一key)

  • t1是空表 —— 直接去掉去重

  • 就算t1不为空, 但t1和t2依然满足第一个条件的话, 也有些优化可以做

  • 但是如果能保证sink scan的数据本身没有重复的话, 就不需要test and add, 只需要test就可以了, 就能节约很多的内存.

如果两个条件都不满足, 且还要70亿规模的赋值, 那就要考虑shuffle了, 不是本issue讨论的内容



### Why is this needed ?

_No response_

### Additional information

_No response_

Activity

  1. added
    kind/tech-request
    on May 24, 2024
  2. self-assigned this
    on May 24, 2024
  3. added this to the 1.3.0-Backlog milestone on May 27, 2024
  4. jensenojs commented on May 28, 2024

    @jensenojs
    ContributorAuthor
  5. jensenojs commented on Jun 12, 2024

    @jensenojs
    ContributorAuthor

    image

    在table scan的stats不可行的背景下, 这个优化缺少了更多意义. 因为Sink Scan被钉死在了Build 端, 那Sink Scan在优化之后也只能是Add, 仍然需要浪费大量内存

  6. jensenojs commented on Jun 18, 2024

    @jensenojs
    ContributorAuthor

    这个pr会改善tableScan Stats更新不及时的问题, 也就是说这个优化可以继续做下去

  7. jensenojs commented on Jun 26, 2024

    @jensenojs
    ContributorAuthor

    后续把优化规则放到plan中 :

    企业微信截图_c483f184-0d7a-4c3b-a315-082f46d37269

  8. modified the milestones: 1.3.0-Backlog, 1.3.0 on Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions