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;
PostgreSQL: | 4.900 |
MySQL: | 2.184 |
SQLite 2.7.6: | 0.914 |
SQLite 2.7.6 (nosync): | 0.757 |
当所有的INSERTs被放入一个事务处理程序时,SQLite不在需要关闭再打开数据库,或者使各个语句间的高速缓存器无效。在结束之前它也不用再执行fsync()s。当解决了这个问题后SQLite 比PostgreSQL和MySQL快很多。.
BEGIN;
CREATE TABLE t3(a INTEGER, b INTEGER, c VARCHAR(100));
CREATE INDEX i3 ON t3(c);
... 24998 lines omitted
INSERT INTO t3 VALUES(24999,88509,'eighty eight thousand five hundred nine');
INSERT INTO t3 VALUES(25000,84791,'eighty four thousand seven hundred ninety one');
COMMIT;
PostgreSQL: | 8.175 |
MySQL: | 3.197 |
SQLite 2.7.6: | 1.555 |
SQLite 2.7.6 (nosync): | 1.402 |
有报告说SQLite在编入索引的表格中表现的不是很好。这个测试证明事实不是这样的,虽然SQLite在创建索引登录时不是很快,但它整体的速度仍是比PostgreSQL和MySQL快。
BEGIN;
SELECT count(*), avg(b) FROM t2 WHERE b>=0 AND b<1000;
SELECT count(*), avg(b) FROM t2 WHERE b>=100 AND b<1100;
... 96 lines omitted
SELECT count(*), avg(b) FROM t2 WHERE b>=9800 AND b<10800;
SELECT count(*), avg(b) FROM t2 WHERE b>=9900 AND b<10900;
COMMIT;
PostgreSQL: | 3.629 |
MySQL: | 2.760 |
SQLite 2.7.6: | 2.494 |
SQLite 2.7.6 (nosync): | 2.526 |
这个测试是在一个没有索引的25000登录表格中进行100查询,所以需要浏览一个完整的表格。 SQLite之前的版本在这个测试上比PostgreSQL和MySQL慢,但最新版本的SQLite是比前两者都快的。
BEGIN;
SELECT count(*), avg(b) FROM t2 WHERE c LIKE '%one%';
SELECT count(*), avg(b) FROM t2 WHERE c LIKE '%two%';
... 96 lines omitted
SELECT count(*), avg(b) FROM t2 WHERE c LIKE '%ninety nine%';
SELECT count(*), avg(b) FROM t2 WHERE c LIKE '%one hundred%';
COMMIT;
PostgreSQL: | 13.409 |
MySQL: | 4.640 |
SQLite 2.7.6: | 3.362 |
SQLite 2.7.6 (nosync): | 3.372 |
这个测试浏览 100 完整表格,但它使用字符串比较,而不是数字比较。This test still does 100 full table scans but it uses uses string comparisons instead of numerical comparisons. SQLite 比PostgreSQL快三倍,比MYSQL快30%。
CREATE INDEX i2a ON t2(a);
CREATE INDEX i2b ON t2(b);
PostgreSQL: | 0.381 |
MySQL: | 0.318 |
SQLite 2.7.6: | 0.777 |
SQLite 2.7.6 (nosync): | 0.659 |
新闻热点
疑难解答