• 请不要在回答技术问题时复制粘贴 AI 生成的内容
dhnUphp
V2EX  ›  程序员

[mysql 插入缓慢]

  •  
  •   dhnUphp · Aug 27, 2015 · 4147 views
    This topic created in 4088 days ago, the information mentioned may be changed or developed.
    三亿数据的表,四个索引。现在插入数据的时候,已经会出现插入缓慢的问题,有没有什么解决办法
    6 replies  •  2015-08-28 08:26:01 +08:00
    ThisDay
    ThisDay
    Aug 27, 2015
    1
    把索引删了,手工建立另外的索引表
    realpg
    realpg
    Aug 27, 2015
    2
    三亿还不分表……
    jnduan
    jnduan
    Aug 27, 2015
    3
    mysql> SHOW GLOBAL VARIABLES LIKE 'innodb_flush_log%';
    +--------------------------------+-------+
    | Variable_name | Value |
    +--------------------------------+-------+
    | innodb_flush_log_at_trx_commit | 1 |
    +--------------------------------+-------+
    1 row in set (0.00 sec )

    查看 innodb_flush_log_at_trx_commit 参数为 1 ,

    临时修改为 2 :
    set global innodb_flush_log_at_trx_commit=2;
    插入性能得到明显提升。
    为确保数据完整,可以在导入完成后将上述参数改回 1 。
    zsmjcnm
    zsmjcnm
    Aug 27, 2015
    4
    你的 INSERT 语句是什么?你的表结构是什么?你的机器配置是什么?
    mahone3297
    mahone3297
    Aug 27, 2015
    5
    可能需要分表。
    invite
    invite
    Aug 28, 2015
    6
    索引多大?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4796 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 01:17 · PVG 09:17 · LAX 17:17 · JFK 20:17
    ♥ Do have faith in what you're doing.