Update the speed comparison page. (CVS 840)
FossilOrigin-Name: 424cb2edb0c51b911791422ce7a9f5284a57f9ce
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
C Fix\sdatatype\sreporting\sand\scollating\ssequence\sselection\sso\sthat\sit\sworks\ncorrectly\son\sviews\sand\swith\sthe\sUNION,\sEXCEPT,\sand\sINTERCEPT\soperators.\s(CVS\s839)
|
||||
D 2003-01-18T20:11:06
|
||||
C Update\sthe\sspeed\scomparison\spage.\s(CVS\s840)
|
||||
D 2003-01-18T22:01:07
|
||||
F Makefile.in 6606854b1512f185b8e8c779b8d7fc2750463d64
|
||||
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
|
||||
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
|
||||
@@ -143,18 +143,18 @@ F www/dynload.tcl 02eb8273aa78cfa9070dd4501dca937fb22b466c
|
||||
F www/faq.tcl 06276ff6c3e369374bb83034cc9d4a7d3a2a34a1
|
||||
F www/fileformat.tcl a4b5c2c6e89b7d42d09f97fd4d7bbd39cbf24936
|
||||
F www/formatchng.tcl b4449e065d2da38b6563bdf12cf46cfe1d4d765e
|
||||
F www/index.tcl 374d30b92a753428baed933623fb9f4259fc5a5c
|
||||
F www/index.tcl b5265ca54a5124ec40bffb7c7943e072e074d61a
|
||||
F www/lang.tcl 1ea38a9fe867e4fed2220f519f5c0862e7022c53
|
||||
F www/mingw.tcl f1c7c0a7f53387dd9bb4f8c7e8571b7561510ebc
|
||||
F www/nulls.tcl 29497dac2bc5b437aa7e2e94577dad4d8933ed26
|
||||
F www/omitted.tcl 118062f40a203fcb88b8d68ef1d7c0073ac191ec
|
||||
F www/opcode.tcl 33c5f2061a05c5d227c72b84c080b3bf74c74f8b
|
||||
F www/quickstart.tcl fde79aa2de20074842b60f780800cdeee6a5dec2
|
||||
F www/speed.tcl a20a792738475b68756ea7a19321600f23d1d803
|
||||
F www/speed.tcl 52759968401d81760fc01f9d3ab6242f6d2a7066
|
||||
F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098
|
||||
F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
|
||||
F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
|
||||
P 32a8e6e9771d636c0ad3042632d35865bc08585b
|
||||
R 04e23a1126d9810e8620977dfdd8daac
|
||||
P 71cc292dce59cf8224b205d1cdbff59ad12f1043
|
||||
R 843340c3fef7e6ee0ac6b3187554a951
|
||||
U drh
|
||||
Z d5604eb0c9b6db0f87d9ac88ab2eea6a
|
||||
Z 66212ef777c3998af30d067a457e17bb
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
71cc292dce59cf8224b205d1cdbff59ad12f1043
|
||||
424cb2edb0c51b911791422ce7a9f5284a57f9ce
|
||||
+4
-3
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# Run this TCL script to generate HTML for the index.html file.
|
||||
#
|
||||
set rcsid {$Id: index.tcl,v 1.71 2003/01/18 20:11:07 drh Exp $}
|
||||
set rcsid {$Id: index.tcl,v 1.72 2003/01/18 22:01:07 drh Exp $}
|
||||
|
||||
puts {<html>
|
||||
<head><title>SQLite: An Embeddable SQL Database Engine</title></head>
|
||||
@@ -57,8 +57,9 @@ puts {<h2>Features</h2>
|
||||
different byte orders.</li>
|
||||
<li>Supports databases up to 2 terabytes (2^41 bytes) in size.</li>
|
||||
<li>Small memory footprint: less than 25K lines of C code.</li>
|
||||
<li><a href="speed.html">Four times faster</a> than PostgreSQL.
|
||||
Twice as fast as SQLite 1.0.</li>
|
||||
<li><a href="speed.html">10x faster</a> than PostgreSQL and
|
||||
<a href="speed.html">2x faster</a> than MySQL for many common
|
||||
operations.</li>
|
||||
<li>Very simple
|
||||
<a href="c_interface.html">C/C++ interface</a> requires the use of only
|
||||
three functions and one opaque structure.</li>
|
||||
|
||||
+150
-102
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# Run this Tcl script to generate the speed.html file.
|
||||
#
|
||||
set rcsid {$Id: speed.tcl,v 1.8 2002/08/24 18:24:58 drh Exp $ }
|
||||
set rcsid {$Id: speed.tcl,v 1.9 2003/01/18 22:01:07 drh Exp $ }
|
||||
|
||||
puts {<html>
|
||||
<head>
|
||||
@@ -19,25 +19,42 @@ puts {
|
||||
<h2>Executive Summary</h2>
|
||||
|
||||
<p>A series of tests were run to measure the relative performance of
|
||||
SQLite 2.7.0, PostgreSQL 7.1.3, and MySQL 3.23.41.
|
||||
SQLite 2.7.6, PostgreSQL 7.1.3, and MySQL 3.23.41.
|
||||
The following are general
|
||||
conclusions drawn from these experiments:
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li><p>
|
||||
SQLite 2.7.0 is significantly faster than PostgreSQL 7.1.3
|
||||
for most common operations.
|
||||
SQLite 2.7.6 is significantly faster (sometimes as much as 10 or
|
||||
20 times faster) than PostgreSQL 7.1.3
|
||||
for most common operations.
|
||||
</p></li>
|
||||
<li><p>
|
||||
The speed of SQLite 2.7.0 is similar to MySQL 3.23.41.
|
||||
This is true in spite of the
|
||||
fact that SQLite contains full transaction support whereas the
|
||||
version of MySQL tested did not.
|
||||
SQLite 2.7.6 is usually faster than MySQL 3.23.41 (sometimes
|
||||
more than twice as fast) though for some operations such as
|
||||
full table scans, it can be as much as 30% slower.
|
||||
</p></li>
|
||||
<li><p>
|
||||
SQLite does not execute CREATE INDEX or DROP TABLE as fast as
|
||||
the other databases. But this as not seen is a problem because
|
||||
those are infrequent operations.
|
||||
</p></li>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
The results presented here come with the following caveats:
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li><p>
|
||||
These tests did not attempt to measure multi-user performance or
|
||||
optimization of complex queries involving multiple joins and subqueries.
|
||||
</p></li>
|
||||
<li><p>
|
||||
These tests are on a relatively small (approximately 10 megabyte) database.
|
||||
They do not measure how well the database engines scale to larger problems.
|
||||
</p></li>
|
||||
</ul>
|
||||
|
||||
<h2>Test Environment</h2>
|
||||
@@ -110,10 +127,10 @@ 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');<br>
|
||||
|
||||
</blockquote><table border=0 cellpadding=0 cellspacing=0>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 3.613</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 0.086</td></tr>
|
||||
<tr><td>SQLite 2.7.0:</td><td align="right"> 8.672</td></tr>
|
||||
<tr><td>SQLite 2.7.0 (nosync):</td><td align="right"> 0.286</td></tr>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 3.658</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 0.109</td></tr>
|
||||
<tr><td>SQLite 2.7.6:</td><td align="right"> 7.177</td></tr>
|
||||
<tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 0.266</td></tr>
|
||||
</table>
|
||||
|
||||
<p>SQLite must close and reopen the database file, and thus invalidate
|
||||
@@ -122,6 +139,7 @@ version of SQLite is still nearly as fast as MySQL. Notice how much slower
|
||||
the synchronous version is, however. This is due to the necessity of
|
||||
calling <b>fsync()</b> after each SQL statement.</p>
|
||||
|
||||
|
||||
<h2>Test 2: 25000 INSERTs in a transaction</h2>
|
||||
<blockquote>
|
||||
BEGIN;<br>
|
||||
@@ -133,10 +151,10 @@ INSERT INTO t2 VALUES(25000,473330,'four hundred seventy three thousand three hu
|
||||
COMMIT;<br>
|
||||
|
||||
</blockquote><table border=0 cellpadding=0 cellspacing=0>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 4.430</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 2.025</td></tr>
|
||||
<tr><td>SQLite 2.7.0:</td><td align="right"> 0.885</td></tr>
|
||||
<tr><td>SQLite 2.7.0 (nosync):</td><td align="right"> 0.753</td></tr>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 5.058</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 2.271</td></tr>
|
||||
<tr><td>SQLite 2.7.6:</td><td align="right"> 0.912</td></tr>
|
||||
<tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 0.798</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
@@ -148,62 +166,66 @@ this way, SQLite is much faster than either PostgreSQL and MySQL.
|
||||
|
||||
<h2>Test 3: 100 SELECTs without an index</h2>
|
||||
<blockquote>
|
||||
BEGIN;<br>
|
||||
SELECT count(*), avg(b) FROM t2 WHERE b>=0 AND b<1000;<br>
|
||||
SELECT count(*), avg(b) FROM t2 WHERE b>=100 AND b<1100;<br>
|
||||
SELECT count(*), avg(b) FROM t2 WHERE b>=200 AND b<1200;<br>
|
||||
<i>... 94 lines omitted</i><br>
|
||||
SELECT count(*), avg(b) FROM t2 WHERE b>=9700 AND b<10700;<br>
|
||||
<i>... 96 lines omitted</i><br>
|
||||
SELECT count(*), avg(b) FROM t2 WHERE b>=9800 AND b<10800;<br>
|
||||
SELECT count(*), avg(b) FROM t2 WHERE b>=9900 AND b<10900;<br>
|
||||
COMMIT;<br>
|
||||
|
||||
</blockquote><table border=0 cellpadding=0 cellspacing=0>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 3.274</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 2.624</td></tr>
|
||||
<tr><td>SQLite 2.7.0:</td><td align="right"> 5.585</td></tr>
|
||||
<tr><td>SQLite 2.7.0 (nosync):</td><td align="right"> 5.443</td></tr>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 3.657</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 3.368</td></tr>
|
||||
<tr><td>SQLite 2.7.6:</td><td align="right"> 4.386</td></tr>
|
||||
<tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 4.314</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
This test does 100 queries on a 25000 entry table without an index,
|
||||
thus requiring a full table scan. SQLite is about half the speed of
|
||||
PostgreSQL and MySQL. This is because SQLite stores all data as strings
|
||||
and must therefore call <b>strtod()</b> 5 million times in the
|
||||
thus requiring a full table scan. SQLite is about 20% or 30% slower
|
||||
than PostgreSQL and MySQL. The reason for this is believed to be
|
||||
because SQLite stores all data as strings
|
||||
and must therefore do 5 million string-to-number conversions in the
|
||||
course of evaluating the WHERE clauses. Both PostgreSQL and MySQL
|
||||
store data as binary values where appropriate and can forego
|
||||
this conversion effort.
|
||||
</p>
|
||||
|
||||
|
||||
<h2>Test 4: 100 SELECTs on a string comparison</h2>
|
||||
<blockquote>
|
||||
BEGIN;<br>
|
||||
SELECT count(*), avg(b) FROM t2 WHERE c LIKE '%one%';<br>
|
||||
SELECT count(*), avg(b) FROM t2 WHERE c LIKE '%two%';<br>
|
||||
SELECT count(*), avg(b) FROM t2 WHERE c LIKE '%three%';<br>
|
||||
<i>... 94 lines omitted</i><br>
|
||||
SELECT count(*), avg(b) FROM t2 WHERE c LIKE '%ninety eight%';<br>
|
||||
<i>... 96 lines omitted</i><br>
|
||||
SELECT count(*), avg(b) FROM t2 WHERE c LIKE '%ninety nine%';<br>
|
||||
SELECT count(*), avg(b) FROM t2 WHERE c LIKE '%one hundred%';<br>
|
||||
COMMIT;<br>
|
||||
|
||||
</blockquote><table border=0 cellpadding=0 cellspacing=0>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 14.511</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 4.616</td></tr>
|
||||
<tr><td>SQLite 2.7.0:</td><td align="right"> 5.966</td></tr>
|
||||
<tr><td>SQLite 2.7.0 (nosync):</td><td align="right"> 5.918</td></tr>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 15.967</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 5.088</td></tr>
|
||||
<tr><td>SQLite 2.7.6:</td><td align="right"> 5.419</td></tr>
|
||||
<tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 5.367</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
This set of 100 queries uses string comparisons instead of
|
||||
numerical comparisions. As a result, the speed of SQLite is
|
||||
compariable to or better then PostgreSQL and MySQL.
|
||||
This test still does 100 full table scans but it uses
|
||||
uses string comparisons instead of numerical comparisions.
|
||||
SQLite is almost three times faster than PostgreSQL here. But it is
|
||||
still 15% slower than MySQL. MySQL appears to be very good
|
||||
at doing full table scans.
|
||||
</p>
|
||||
|
||||
<h2>Test 5: Creating an index</h2>
|
||||
<blockquote>
|
||||
CREATE INDEX i2a ON t2(a);<br>CREATE INDEX i2b ON t2(b);
|
||||
</blockquote><table border=0 cellpadding=0 cellspacing=0>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 0.483</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 0.304</td></tr>
|
||||
<tr><td>SQLite 2.7.0:</td><td align="right"> 0.779</td></tr>
|
||||
<tr><td>SQLite 2.7.0 (nosync):</td><td align="right"> 0.637</td></tr>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 0.431</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 0.340</td></tr>
|
||||
<tr><td>SQLite 2.7.6:</td><td align="right"> 0.814</td></tr>
|
||||
<tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 0.675</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
@@ -223,15 +245,15 @@ SELECT count(*), avg(b) FROM t2 WHERE b>=499800 AND b<499900;<br>
|
||||
SELECT count(*), avg(b) FROM t2 WHERE b>=499900 AND b<500000;<br>
|
||||
|
||||
</blockquote><table border=0 cellpadding=0 cellspacing=0>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 4.939</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 1.335</td></tr>
|
||||
<tr><td>SQLite 2.7.0:</td><td align="right"> 1.165</td></tr>
|
||||
<tr><td>SQLite 2.7.0 (nosync):</td><td align="right"> 1.144</td></tr>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 5.369</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 1.489</td></tr>
|
||||
<tr><td>SQLite 2.7.6:</td><td align="right"> 1.423</td></tr>
|
||||
<tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 1.358</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
This test runs a set of 5000 queries that are similar in form to
|
||||
those in test 3. But now instead of being half as fast, SQLite
|
||||
those in test 3. But now instead of being slower, SQLite
|
||||
is faster than both PostgreSQL and MySQL.
|
||||
</p>
|
||||
|
||||
@@ -246,15 +268,18 @@ UPDATE t1 SET b=b*2 WHERE a>=9990 AND a<10000;<br>
|
||||
COMMIT;<br>
|
||||
|
||||
</blockquote><table border=0 cellpadding=0 cellspacing=0>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 1.536</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 7.281</td></tr>
|
||||
<tr><td>SQLite 2.7.0:</td><td align="right"> 0.817</td></tr>
|
||||
<tr><td>SQLite 2.7.0 (nosync):</td><td align="right"> 0.726</td></tr>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 1.740</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 8.162</td></tr>
|
||||
<tr><td>SQLite 2.7.6:</td><td align="right"> 0.635</td></tr>
|
||||
<tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 0.608</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
Here is a case where MySQL is over 10 times slower than SQLite.
|
||||
The reason for this is unclear.
|
||||
For this particular UPDATE test, MySQL is consistently
|
||||
five or ten times
|
||||
slower than PostgreSQL and SQLite. I do not know why. MySQL is
|
||||
normally a very fast engine. Perhaps this problem has been addressed
|
||||
in later versions of MySQL.
|
||||
</p>
|
||||
|
||||
<h2>Test 8: 25000 UPDATEs with an index</h2>
|
||||
@@ -268,16 +293,16 @@ UPDATE t2 SET b=423958 WHERE a=25000;<br>
|
||||
COMMIT;<br>
|
||||
|
||||
</blockquote><table border=0 cellpadding=0 cellspacing=0>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 29.318</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 7.514</td></tr>
|
||||
<tr><td>SQLite 2.7.0:</td><td align="right"> 7.681</td></tr>
|
||||
<tr><td>SQLite 2.7.0 (nosync):</td><td align="right"> 7.852</td></tr>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 32.118</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 8.132</td></tr>
|
||||
<tr><td>SQLite 2.7.6:</td><td align="right"> 4.109</td></tr>
|
||||
<tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 3.712</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
In this case MySQL is slightly faster than SQLite, though not by much.
|
||||
The difference is believed to have to do with the fact SQLite
|
||||
handles the integers as strings instead of binary numbers.
|
||||
As recently as version 2.7.0, SQLite ran at about the same speed as
|
||||
MySQL on this test. But recent optimizations to SQLite have doubled
|
||||
speed of UPDATEs.
|
||||
</p>
|
||||
|
||||
<h2>Test 9: 25000 text UPDATEs with an index</h2>
|
||||
@@ -291,72 +316,83 @@ UPDATE t2 SET c='three hundred forty seven thousand three hundred ninety three'
|
||||
COMMIT;<br>
|
||||
|
||||
</blockquote><table border=0 cellpadding=0 cellspacing=0>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 50.020</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 5.841</td></tr>
|
||||
<tr><td>SQLite 2.7.0:</td><td align="right"> 5.346</td></tr>
|
||||
<tr><td>SQLite 2.7.0 (nosync):</td><td align="right"> 5.393</td></tr>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 55.309</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 6.585</td></tr>
|
||||
<tr><td>SQLite 2.7.6:</td><td align="right"> 2.474</td></tr>
|
||||
<tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 1.800</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
When updating a text field instead of an integer field,
|
||||
SQLite is slightly faster than MySQL.
|
||||
Here again, version 2.7.0 of SQLite used to run at about the same speed
|
||||
as MySQL. But now version 2.7.6 is over two times faster than MySQL and
|
||||
over twenty times faster than PostgreSQL.
|
||||
</p>
|
||||
|
||||
<h2>Test 10: INSERTs from a SELECT</h2>
|
||||
<blockquote>
|
||||
BEGIN;<br>INSERT INTO t1 SELECT * FROM t2;<br>INSERT INTO t2 SELECT * FROM t1;<br>COMMIT;
|
||||
BEGIN;<br>INSERT INTO t1 SELECT b,a,c FROM t2;<br>INSERT INTO t2 SELECT b,a,c FROM t1;<br>COMMIT;
|
||||
</blockquote><table border=0 cellpadding=0 cellspacing=0>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 57.834</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 1.335</td></tr>
|
||||
<tr><td>SQLite 2.7.0:</td><td align="right"> 5.073</td></tr>
|
||||
<tr><td>SQLite 2.7.0 (nosync):</td><td align="right"> 2.085</td></tr>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 58.956</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 1.465</td></tr>
|
||||
<tr><td>SQLite 2.7.6:</td><td align="right"> 2.926</td></tr>
|
||||
<tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 1.664</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
The poor performance of PostgreSQL in this case appears to be due to its
|
||||
synchronous behavior. The CPU was mostly idle the test run. Presumably,
|
||||
PostgreSQL was spending most of its time waiting on disk I/O to complete.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
SQLite is slower than MySQL because it creates a temporary table to store
|
||||
the result of the query, then does an insert from the temporary table.
|
||||
A future enhancement that moves data directly from teh query into the
|
||||
insert table should double the speed of SQLite.
|
||||
I'm not sure why SQLite performs poorly here. It use to be quicker at this
|
||||
test, but the same enhancements that sped up the UPDATE logic seem to have
|
||||
slowed down this test.
|
||||
</p>
|
||||
|
||||
<h2>Test 11: DELETE without an index</h2>
|
||||
<blockquote>
|
||||
DELETE FROM t2 WHERE c LIKE '%fifty%';
|
||||
</blockquote><table border=0 cellpadding=0 cellspacing=0>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 0.733</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 0.768</td></tr>
|
||||
<tr><td>SQLite 2.7.0:</td><td align="right"> 5.418</td></tr>
|
||||
<tr><td>SQLite 2.7.0 (nosync):</td><td align="right"> 0.668</td></tr>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 1.365</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 0.849</td></tr>
|
||||
<tr><td>SQLite 2.7.6:</td><td align="right"> 4.005</td></tr>
|
||||
<tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 0.631</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
The synchronous version of SQLite is the slowest of the group in this test,
|
||||
but the asynchronous version is the fastest. SQLite used about the same
|
||||
amount of CPU time in both versions; the difference is the extra time needed
|
||||
to write information to the disk surface.
|
||||
</p>
|
||||
|
||||
<h2>Test 12: DELETE with an index</h2>
|
||||
<blockquote>
|
||||
DELETE FROM t2 WHERE a>10 AND a<20000;
|
||||
</blockquote><table border=0 cellpadding=0 cellspacing=0>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 0.867</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 2.068</td></tr>
|
||||
<tr><td>SQLite 2.7.0:</td><td align="right"> 1.453</td></tr>
|
||||
<tr><td>SQLite 2.7.0 (nosync):</td><td align="right"> 0.745</td></tr>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 1.340</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 2.167</td></tr>
|
||||
<tr><td>SQLite 2.7.6:</td><td align="right"> 2.344</td></tr>
|
||||
<tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 0.858</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
This test is significant because it is one of the few where
|
||||
PostgreSQL is faster than MySQL. The asynchronous SQLite is,
|
||||
however, faster then both the other two.
|
||||
</p>
|
||||
|
||||
</table>
|
||||
<h2>Test 13: A big INSERT after a big DELETE</h2>
|
||||
<blockquote>
|
||||
INSERT INTO t2 SELECT * FROM t1;
|
||||
</blockquote><table border=0 cellpadding=0 cellspacing=0>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 66.099</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 1.663</td></tr>
|
||||
<tr><td>SQLite 2.7.0:</td><td align="right"> 4.029</td></tr>
|
||||
<tr><td>SQLite 2.7.0 (nosync):</td><td align="right"> 1.729</td></tr>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 12.672</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 1.837</td></tr>
|
||||
<tr><td>SQLite 2.7.6:</td><td align="right"> 3.076</td></tr>
|
||||
<tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 1.570</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
Earlier versions of SQLite would show decreasing performance after a
|
||||
Some older versions of SQLite would show decreasing performance after a
|
||||
sequence DELETEs followed by new INSERTs. As this test shows, the
|
||||
problem has now been resolved.
|
||||
</p>
|
||||
@@ -366,32 +402,44 @@ problem has now been resolved.
|
||||
BEGIN;<br>
|
||||
DELETE FROM t1;<br>
|
||||
INSERT INTO t1 VALUES(1,29676,'twenty nine thousand six hundred seventy six');<br>
|
||||
<i>... 2997 lines omitted</i><br>
|
||||
INSERT INTO t1 VALUES(2999,37835,'thirty seven thousand eight hundred thirty five');<br>
|
||||
INSERT INTO t1 VALUES(3000,97817,'ninety seven thousand eight hundred seventeen');<br>
|
||||
<i>... 11997 lines omitted</i><br>
|
||||
INSERT INTO t1 VALUES(11999,71818,'seventy one thousand eight hundred eighteen');<br>
|
||||
INSERT INTO t1 VALUES(12000,58579,'fifty eight thousand five hundred seventy nine');<br>
|
||||
COMMIT;<br>
|
||||
|
||||
</blockquote><table border=0 cellpadding=0 cellspacing=0>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 1.168</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 0.866</td></tr>
|
||||
<tr><td>SQLite 2.7.0:</td><td align="right"> 0.288</td></tr>
|
||||
<tr><td>SQLite 2.7.0 (nosync):</td><td align="right"> 0.155</td></tr>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 4.165</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 1.733</td></tr>
|
||||
<tr><td>SQLite 2.7.6:</td><td align="right"> 0.652</td></tr>
|
||||
<tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 0.465</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
SQLite is very good at doing INSERTs within a transaction, which probably
|
||||
explains why it is so much faster than the other databases at this test.
|
||||
</p>
|
||||
|
||||
<h2>Test 15: DROP TABLE</h2>
|
||||
<blockquote>
|
||||
DROP TABLE t1;<br>DROP TABLE t2;
|
||||
</blockquote><table border=0 cellpadding=0 cellspacing=0>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 0.100</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 0.012</td></tr>
|
||||
<tr><td>SQLite 2.7.0:</td><td align="right"> 0.572</td></tr>
|
||||
<tr><td>SQLite 2.7.0 (nosync):</td><td align="right"> 0.168</td></tr>
|
||||
<tr><td>PostgreSQL:</td><td align="right"> 0.133</td></tr>
|
||||
<tr><td>MySQL:</td><td align="right"> 0.014</td></tr>
|
||||
<tr><td>SQLite 2.7.6:</td><td align="right"> 0.873</td></tr>
|
||||
<tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 0.224</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
SQLite is slower than the other databases when it comes to dropping tables.
|
||||
This is not seen as a big problem, however, since DROP TABLE is seldom
|
||||
used in speed-critical situations.
|
||||
This probably is because when SQLite drops a table, it has to go through and
|
||||
erase the records in the database file that deal with that table. MySQL and
|
||||
PostgreSQL, on the other hand, use separate files to represent each table
|
||||
so they can drop a table simply by deleting a file, which is much faster.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
On the other hand, dropping tables is not a very common operation
|
||||
so if SQLite takes a little longer, that is not seen as a big problem.
|
||||
</p>
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user