我正在做一些性能比较,无论是用于序列化数据还是将其存储在数据库中。该应用程序收到大量需要以最低18mb/s的速度保持的数据(x GB)(目前)
在以后的搜索和访问数据,数据快照,数据迁移等方面,存储在数据库中提供了更轻松的功能,但是到目前为止,我的测试显示出性能时间上的巨大差异。
该测试可保存1000个对象(每个对象大约7千kb)。通过将它们另存为通用列表,可以将它们存储在表中的相应列中,也可以存储到磁盘中。 (SQLite结束时会有更多数据)
我还没有对SQLite进行任何性能调整,只需将它与Fluent nHibernate和SQLite.Data适配器(无事务)一起使用即可,但是起初认为这是一个巨大的差异。
显然,我知道与串行化相比,通过ORM映射器和DB写入磁盘会产生开销,但是这很多。
当我收到数据时,还应考虑立即保留数据。如果发生电源故障,我需要接收最后的数据。
有什么想法吗?
-----更新(我将继续研究解决方案)------
最佳答案
我曾经有一个similar problem,建议您使用SQLite路由。
至于您的效能问题,如果您:
测试1:1000次插入
CREATE TABLE t1(a INTEGER, b INTEGER, c VARCHAR(100));
INSERT INTO t1 VALUES(1,13153,'thirteen thousand one hundred fifty three');
INSERT INTO t1 VALUES(2,75560,'seventy five thousand five hundred sixty');
... 995 lines omitted
INSERT INTO t1 VALUES(998,66289,'sixty six thousand two hundred eighty nine');
INSERT INTO t1 VALUES(999,24322,'twenty four thousand three hundred twenty two');
INSERT INTO t1 VALUES(1000,94142,'ninety four thousand one hundred forty two');
测试2:一个事务中有25000个INSERT
BEGIN;
CREATE TABLE t2(a INTEGER, b INTEGER, c VARCHAR(100));
INSERT INTO t2 VALUES(1,59672,'fifty nine thousand six hundred seventy two');
... 24997 lines omitted
INSERT INTO t2 VALUES(24999,89569,'eighty nine thousand five hundred sixty nine');
INSERT INTO t2 VALUES(25000,94666,'ninety four thousand six hundred sixty six');
COMMIT;
***这些基准是针对SQLite 2的SQLite 3 should be even faster。