![](https://images2015.cnblogs.com/blog/731047/201612/731047-20161216151813354-29212324.png)
产生测试文件
测试文件部分内容如下:
![](https://images2015.cnblogs.com/blog/731047/201612/731047-20161216151813745-1715031526.png)
产生测试文件代码:
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;
![](https://images2015.cnblogs.com/blog/731047/201612/731047-20161216151814573-2078195184.png)
![](https://images2015.cnblogs.com/blog/731047/201612/731047-20161216151814901-1953811542.png)
导入数据
load data infile '/home/testFile916M' into table loadtable fields terminated by ',' enclosed by '\'';
![](https://images2015.cnblogs.com/blog/731047/201612/731047-20161216151815245-2020508202.png)
查看入库情况:
![](https://images2015.cnblogs.com/blog/731047/201612/731047-20161216151815776-37123019.png)
另外的入库数据:
![](https://images2015.cnblogs.com/blog/731047/201612/731047-20161216151816058-1520470427.png)
测试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;
![](https://images2015.cnblogs.com/blog/731047/201612/731047-20161216151816479-1217698539.png)
导入数据
load data infile '/home/ib916M' into table loadtable fields terminated by ',' enclosed by '\'';
![](https://images2015.cnblogs.com/blog/731047/201612/731047-20161216151816933-597323624.png)
查看入库结果:
![](https://images2015.cnblogs.com/blog/731047/201612/731047-20161216151817354-605851486.png)
另外的入库数据:
![](https://images2015.cnblogs.com/blog/731047/201612/731047-20161216151817698-1774160832.png)
总结
- mysql入库:1500万条数据,约900M,入库时间大约在5min左右;
- Infobright入库:1500万条数据,约900M,入库时间大约在2~3min左右;
转载请标明出处:http://www.cnblogs.com/ssslinppp/