产生测试文件
测试文件部分内容如下:
产生测试文件代码:
package foo;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class WriteIBdata {
public static void main(String[] args) {
String file = "C:\\linliu\\ib666";
writeFile(file);
}
public static void writeFile(String fileName) {
try {
FileWriter fw = new FileWriter(new File(fileName));
for (int i = 0; i < 10000 * 1500; i++) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
fw.write("'");
fw.write(sdf.format(new Date()));
fw.write("'");
fw.write(",");
fw.write("'");
fw.write(String.valueOf(System.nanoTime()));
fw.write("'");
fw.write(",");
fw.write("'");
fw.write("aaaaaaaaaaaaaaaaaaaa");
fw.write("'");
fw.write("\n");
if (i % 50000 == 0) {
System.out.println("Finish:" + i/50000);
}
}
fw.close();
} catch (IOException e1) {
}
}
}
测试Mysql数据库
创建数据表
CREATE TABLE `loadtable` (
`insertTstamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`logType` varchar(64) NOT NULL,
`content` varchar(64) NOT NULL,
PRIMARY KEY (`insertTstamp`,`logType`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
导入数据
load data infile '/home/testFile916M' into table loadtable fields terminated by ',' enclosed by '\'';
查看入库情况:
另外的入库数据:
测试Infobright数据库
创建数据表
CREATE TABLE `loadtable` (
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`type` varchar(64) NOT NULL,
`content` varchar(64) NOT NULL
) ENGINE=BRIGHTHOUSE DEFAULT CHARSET=utf8;
导入数据
load data infile '/home/ib916M' into table loadtable fields terminated by ',' enclosed by '\'';
查看入库结果:
另外的入库数据:
总结
- mysql入库:1500万条数据,约900M,入库时间大约在5min左右;
- Infobright入库:1500万条数据,约900M,入库时间大约在2~3min左右;