MyISAM与InnoDB进行日志记录

时间:2015-03-11 14:42:17

标签: mysql logging innodb myisam

我正在优化数据库,几乎不知道我的学士论文。我绝不想让你为我做的工作,但我有一些问题,到目前为止没有人能回答。

表格结构:

data_inc, CREATE TABLE 'data_inc' ( 'id' bigint(20) NOT NULL AUTO_INCREMENT, 'id_para' int(10) unsigned NOT NULL DEFAULT '0', 't_s' int(11) unsigned NOT NULL DEFAULT '0', 't_ms' smallint(6) unsigned NOT NULL DEFAULT '0', 't_ns' bigint(20) unsigned NOT NULL DEFAULT '0', 'id_inst' smallint(6) NOT NULL DEFAULT '1', 'value' varchar(255) NOT NULL DEFAULT '', 'isanchor' tinyint(4) unsigned NOT NULL DEFAULT '0', PRIMARY KEY ('id','t_ns'), KEY 't_s' ('t_s'), KEY 't_ns' ('t_ns') ) ENGINE=MyISAM AUTO_INCREMENT=2128295174 DEFAULT CHARSET=latin1 /* !50100 PARTITION BY RANGE (t_ns) (PARTITION 19_02_2015_23_59 VALUES LESS THAN (1424386799000000000) ENGINE = MyISAM, PARTITION 20_02_2015_23_59 VALUES LESS THAN (1424473199000000000) ENGINE = MyISAM, PARTITION 21_02_2015_23_59 VALUES LESS THAN (1424559599000000000) ENGINE = MyISAM, PARTITION 22_02_2015_23_59 VALUES LESS THAN (1424645999000000000) ENGINE = MyISAM, PARTITION 23_02_2015_23_59 VALUES LESS THAN (1424732399000000000) ENGINE = MyISAM, PARTITION 24_02_2015_23_59 VALUES LESS THAN (1424818799000000000) ENGINE = MyISAM, PARTITION 25_02_2015_23_59 VALUES LESS THAN (1424905199000000000) ENGINE = MyISAM, PARTITION 05_03_2015_23_59 VALUES LESS THAN (1425596399000000000) ENGINE = MyISAM, PARTITION 13_03_2015_23_59 VALUES LESS THAN (1426287599000000000) ENGINE = MyISAM, PARTITION 14_03_2015_23_59 VALUES LESS THAN (1426373999000000000) ENGINE = MyISAM, PARTITION 15_03_2015_23_59 VALUES LESS THAN (1426460399000000000) ENGINE = MyISAM, PARTITION 16_03_2015_23_59 VALUES LESS THAN (1426546799000000000) ENGINE = MyISAM, PARTITION 17_03_2015_23_59 VALUES LESS THAN (1426633199000000000) ENGINE = MyISAM, PARTITION 18_03_2015_23_59 VALUES LESS THAN (1426719599000000000) ENGINE = MyISAM) */

系统当前每秒最多将4000个参数记录到数据库中(不同的表,其中一个在存储过程中决定)。每隔5分钟,1小时和每天不同的脚本被调用来分析日志数据,在此期间数据被写入表中。这导致一些重负荷现在。是否有可能从MyISAM切换到InnoDB(或其他),性能会提高?

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

快速记录,然后进行分析......

  1. 将数据收集到没有索引的MyISAM表中。 5分钟后(1.2M行!):
  2. 将其分析为InnoDB“摘要表”。
  3. DROP TABLE或TRUNCATE TABLE。
  4. 分析将放入其他表格中。这些将包含摘要信息,并且小于1.2M行。

    要获取每小时数据,请汇总摘要表。但是不要创建“每小时”表;只需根据需要获取并重新计算。

    以下是一些相关讨论:High speed ingestionSummary Tables