Skip to content

[Bug]: Inserting record is very slow #13987

Closed

Description

@DanielZhangQD

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

1.1-dev

Commit ID

b90bf97

Other Environment Information

- Hardware parameters:
- OS type:
- Others:

Actual Behavior

Insert less than 200 rows and get the following result:

2024/01/03 12:01:53.735266 +0000 WARN [email protected]/finisher_api.go:647 trace {"elapsed": "2m6.871143051s", "rows": 196, "sql": "INSERT INTO `mo_catalog`.`statement_cu` (`statement_id`,`account`,`response_at`,`cu`,`account_id`) VALUES (...)

Expected Behavior

The query succeeds in short time

Steps to Reproduce

NA

Additional information

Dev env
For detailed schema and SQLs, refer to https://github.com/matrixorigin/MO-Cloud/issues/2200

Activity

  1. added
    kind/bug
    severity/s0
    on Jan 3, 2024
  2. added this to the 1.1.0 milestone on Jan 3, 2024
  3. DanielZhangQD commented on Jan 3, 2024

    @DanielZhangQD
    ContributorAuthor
    MySQL [mo_cloud]> select statement_id,status,duration from system.statement_info where statement like '%INSERT INTO `mo_catalog`.`statement_cu`%' and request_at >= '2024-01-03 12:00:00' order by duration desc;
    +--------------------------------------+---------+--------------+
    | statement_id                         | status  | duration     |
    +--------------------------------------+---------+--------------+
    | 40a1f570-aa32-11ee-938e-729694d477be | Success | 148216126487 |
    | 95c37f18-aa31-11ee-938e-729694d477be | Success | 125535215584 |
    | 200af7e8-aa35-11ee-938e-729694d477be | Success | 122606068196 |
    | 4aabe79e-aa33-11ee-938e-729694d477be | Success | 117256103508 |
    
  4. jensenojs commented on Jan 4, 2024

    @jensenojs
    Contributor

    我在dev环境上复制了一张statement_cu表出来, 然后模拟https://github.com/matrixorigin/MO-Cloud/issues/2200的方式往里面插入数据, 并用explain analyze 查看每个节点的耗时情况, 耗时最长的是table scan, 之前的慢有没有可能是s3的时延?

    image image
  5. 17 remaining items

  6. ouyuanning commented on Jan 19, 2024

    @ouyuanning
    Contributor

    比如:
    create table t1 (a int, b int, primary key(a,b));
    insert into t1 values (1,1),(2,2),(3,3);

    锦赛先比较一下这些方式的性能吧。(行数可以看下3 行, 30行, 300行,不同行数的情况)
    1: (a=1 and b=1) or (a=2 and b=2) and or (a=3 and b=3)
    2: pk in (serial(1,1), serial(2,2), serial(3,3))
    3: a in (1,2,3);
    4: 留空,全表扫
    然后选性能好的方案就好了

  7. ouyuanning commented on Jan 19, 2024

    @ouyuanning
    Contributor

    其实你可以试一下直接用 select语句测,应该效果是一样的

  8. ouyuanning commented on Jan 19, 2024

    @ouyuanning
    Contributor

    还有一个。 filter_list 可能也可以根据情况来确定是否放进去。

  9. modified the milestones: 1.2.0, 1.1.0 on Jan 22, 2024
  10. modified the milestones: 1.1.0, 1.2.0 on Jan 22, 2024
  11. jensenojs commented on Feb 18, 2024

    @jensenojs
    Contributor

    @DanielZhangQD 现在插入的速度能够接受吗, 龙冉哥的相关pr已经merge进去了

  12. jensenojs commented on Feb 22, 2024

    @jensenojs
    Contributor

    可能还需要继续做..?

  13. jensenojs commented on Mar 22, 2024

    @jensenojs
    Contributor

    复现方式

    use mo_catalog;
    
    CREATE CLUSTER TABLE `statement_cu` (
    `statement_id` VARCHAR(36) NOT NULL,
    `account` VARCHAR(300) NOT NULL,
    `response_at` INT DEFAULT NULL, # 修改了这个项的类型, 方便生成数据
    `cu` int NOT NULL,
    PRIMARY KEY (`statement_id`,`account_id`)
    )
    
    # 分批多次调用, 产生足够的数据
    insert into test (statement_id, account_id, account, cu) select result || "cc", 1, '', 1 from generate_series (1, 3000000)g;
    
    explain analyze INSERT INTO `mo_catalog`.`statement_cu` (`statement_id`,`account`,`response_at`,`cu`,`account_id`) VALUES ('0fa1346a-9aef-11ee-86a0-3acc4192c386','ba537a2b_43e7_4a2c_a6fe_b945278ef41a',1,1 ,24000002);

    复现结果

    企业微信截图_ff1bb3de-f94d-4148-890c-cab311ff8734

    可以看到table scan读上来的数据已经被全部过滤掉了, 和之前的inputRows有对比

    现在这个问题已经有很多pr在不同的层面上fix了, 而且相关的业务也已经被停掉了, 所以只能手动造数据来测, 已经跟海龙哥和远宁哥确认

    我在dev环境上复制了一张statement_cu表出来, 然后模拟https://github.com/matrixorigin/MO-Cloud/issues/2200的方式往里面插入数据, 并用explain analyze 查看每个节点的耗时情况, 耗时最长的是table scan, 之前的慢有没有可能是s3的时延?

    image image

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

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0team/c2

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions