diff options
Diffstat (limited to 'libraries/sqlite/unix/sqlite-3.5.1/www/speed.tcl')
-rw-r--r-- | libraries/sqlite/unix/sqlite-3.5.1/www/speed.tcl | 495 |
1 files changed, 495 insertions, 0 deletions
diff --git a/libraries/sqlite/unix/sqlite-3.5.1/www/speed.tcl b/libraries/sqlite/unix/sqlite-3.5.1/www/speed.tcl new file mode 100644 index 0000000..b60cfe1 --- /dev/null +++ b/libraries/sqlite/unix/sqlite-3.5.1/www/speed.tcl | |||
@@ -0,0 +1,495 @@ | |||
1 | # | ||
2 | # Run this Tcl script to generate the speed.html file. | ||
3 | # | ||
4 | set rcsid {$Id: speed.tcl,v 1.17 2005/03/12 15:55:11 drh Exp $ } | ||
5 | source common.tcl | ||
6 | header {SQLite Database Speed Comparison} | ||
7 | |||
8 | puts { | ||
9 | <h2>Database Speed Comparison</h2> | ||
10 | |||
11 | <font color="red"><b> | ||
12 | Note: This document is old. It describes a speed comparison between | ||
13 | an older version of SQLite against archaic versions of MySQL and PostgreSQL. | ||
14 | Readers are invited to contribute more up-to-date speed comparisons | ||
15 | on the <a href="http://www.sqlite.org/cvstrac/wiki">SQLite Wiki</a>. | ||
16 | <p> | ||
17 | The numbers here are old enough to be nearly meaningless. Until it is | ||
18 | updated, use this document only as proof that SQLite is not a | ||
19 | sluggard. | ||
20 | </b></font> | ||
21 | |||
22 | <h3>Executive Summary</h3> | ||
23 | |||
24 | <p>A series of tests were run to measure the relative performance of | ||
25 | SQLite 2.7.6, PostgreSQL 7.1.3, and MySQL 3.23.41. | ||
26 | The following are general | ||
27 | conclusions drawn from these experiments: | ||
28 | </p> | ||
29 | |||
30 | <ul> | ||
31 | <li><p> | ||
32 | SQLite 2.7.6 is significantly faster (sometimes as much as 10 or | ||
33 | 20 times faster) than the default PostgreSQL 7.1.3 installation | ||
34 | on RedHat 7.2 for most common operations. | ||
35 | </p></li> | ||
36 | <li><p> | ||
37 | SQLite 2.7.6 is often faster (sometimes | ||
38 | more than twice as fast) than MySQL 3.23.41 | ||
39 | for most common operations. | ||
40 | </p></li> | ||
41 | <li><p> | ||
42 | SQLite does not execute CREATE INDEX or DROP TABLE as fast as | ||
43 | the other databases. But this is not seen as a problem because | ||
44 | those are infrequent operations. | ||
45 | </p></li> | ||
46 | <li><p> | ||
47 | SQLite works best if you group multiple operations together into | ||
48 | a single transaction. | ||
49 | </p></li> | ||
50 | </ul> | ||
51 | |||
52 | <p> | ||
53 | The results presented here come with the following caveats: | ||
54 | </p> | ||
55 | |||
56 | <ul> | ||
57 | <li><p> | ||
58 | These tests did not attempt to measure multi-user performance or | ||
59 | optimization of complex queries involving multiple joins and subqueries. | ||
60 | </p></li> | ||
61 | <li><p> | ||
62 | These tests are on a relatively small (approximately 14 megabyte) database. | ||
63 | They do not measure how well the database engines scale to larger problems. | ||
64 | </p></li> | ||
65 | </ul> | ||
66 | |||
67 | <h3>Test Environment</h3> | ||
68 | |||
69 | <p> | ||
70 | The platform used for these tests is a 1.6GHz Athlon with 1GB or memory | ||
71 | and an IDE disk drive. The operating system is RedHat Linux 7.2 with | ||
72 | a stock kernel. | ||
73 | </p> | ||
74 | |||
75 | <p> | ||
76 | The PostgreSQL and MySQL servers used were as delivered by default on | ||
77 | RedHat 7.2. (PostgreSQL version 7.1.3 and MySQL version 3.23.41.) | ||
78 | No effort was made to tune these engines. Note in particular | ||
79 | the the default MySQL configuration on RedHat 7.2 does not support | ||
80 | transactions. Not having to support transactions gives MySQL a | ||
81 | big speed advantage, but SQLite is still able to hold its own on most | ||
82 | tests. | ||
83 | </p> | ||
84 | |||
85 | <p> | ||
86 | I am told that the default PostgreSQL configuration in RedHat 7.3 | ||
87 | is unnecessarily conservative (it is designed to | ||
88 | work on a machine with 8MB of RAM) and that PostgreSQL could | ||
89 | be made to run a lot faster with some knowledgeable configuration | ||
90 | tuning. | ||
91 | Matt Sergeant reports that he has tuned his PostgreSQL installation | ||
92 | and rerun the tests shown below. His results show that | ||
93 | PostgreSQL and MySQL run at about the same speed. For Matt's | ||
94 | results, visit | ||
95 | </p> | ||
96 | |||
97 | <blockquote> | ||
98 | <a href="http://www.sergeant.org/sqlite_vs_pgsync.html"> | ||
99 | http://www.sergeant.org/sqlite_vs_pgsync.html</a> | ||
100 | </blockquote> | ||
101 | |||
102 | <p> | ||
103 | SQLite was tested in the same configuration that it appears | ||
104 | on the website. It was compiled with -O6 optimization and with | ||
105 | the -DNDEBUG=1 switch which disables the many "assert()" statements | ||
106 | in the SQLite code. The -DNDEBUG=1 compiler option roughly doubles | ||
107 | the speed of SQLite. | ||
108 | </p> | ||
109 | |||
110 | <p> | ||
111 | All tests are conducted on an otherwise quiescent machine. | ||
112 | A simple Tcl script was used to generate and run all the tests. | ||
113 | A copy of this Tcl script can be found in the SQLite source tree | ||
114 | in the file <b>tools/speedtest.tcl</b>. | ||
115 | </p> | ||
116 | |||
117 | <p> | ||
118 | The times reported on all tests represent wall-clock time | ||
119 | in seconds. Two separate time values are reported for SQLite. | ||
120 | The first value is for SQLite in its default configuration with | ||
121 | full disk synchronization turned on. With synchronization turned | ||
122 | on, SQLite executes | ||
123 | an <b>fsync()</b> system call (or the equivalent) at key points | ||
124 | to make certain that critical data has | ||
125 | actually been written to the disk drive surface. Synchronization | ||
126 | is necessary to guarantee the integrity of the database if the | ||
127 | operating system crashes or the computer powers down unexpectedly | ||
128 | in the middle of a database update. The second time reported for SQLite is | ||
129 | when synchronization is turned off. With synchronization off, | ||
130 | SQLite is sometimes much faster, but there is a risk that an | ||
131 | operating system crash or an unexpected power failure could | ||
132 | damage the database. Generally speaking, the synchronous SQLite | ||
133 | times are for comparison against PostgreSQL (which is also | ||
134 | synchronous) and the asynchronous SQLite times are for | ||
135 | comparison against the asynchronous MySQL engine. | ||
136 | </p> | ||
137 | |||
138 | <h3>Test 1: 1000 INSERTs</h3> | ||
139 | <blockquote> | ||
140 | CREATE TABLE t1(a INTEGER, b INTEGER, c VARCHAR(100));<br> | ||
141 | INSERT INTO t1 VALUES(1,13153,'thirteen thousand one hundred fifty three');<br> | ||
142 | INSERT INTO t1 VALUES(2,75560,'seventy five thousand five hundred sixty');<br> | ||
143 | <i>... 995 lines omitted</i><br> | ||
144 | INSERT INTO t1 VALUES(998,66289,'sixty six thousand two hundred eighty nine');<br> | ||
145 | INSERT INTO t1 VALUES(999,24322,'twenty four thousand three hundred twenty two');<br> | ||
146 | INSERT INTO t1 VALUES(1000,94142,'ninety four thousand one hundred forty two');<br> | ||
147 | |||
148 | </blockquote><table border=0 cellpadding=0 cellspacing=0> | ||
149 | <tr><td>PostgreSQL:</td><td align="right"> 4.373</td></tr> | ||
150 | <tr><td>MySQL:</td><td align="right"> 0.114</td></tr> | ||
151 | <tr><td>SQLite 2.7.6:</td><td align="right"> 13.061</td></tr> | ||
152 | <tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 0.223</td></tr> | ||
153 | </table> | ||
154 | |||
155 | <p> | ||
156 | Because it does not have a central server to coordinate access, | ||
157 | SQLite must close and reopen the database file, and thus invalidate | ||
158 | its cache, for each transaction. In this test, each SQL statement | ||
159 | is a separate transaction so the database file must be opened and closed | ||
160 | and the cache must be flushed 1000 times. In spite of this, the asynchronous | ||
161 | version of SQLite is still nearly as fast as MySQL. Notice how much slower | ||
162 | the synchronous version is, however. SQLite calls <b>fsync()</b> after | ||
163 | each synchronous transaction to make sure that all data is safely on | ||
164 | the disk surface before continuing. For most of the 13 seconds in the | ||
165 | synchronous test, SQLite was sitting idle waiting on disk I/O to complete.</p> | ||
166 | |||
167 | |||
168 | <h3>Test 2: 25000 INSERTs in a transaction</h3> | ||
169 | <blockquote> | ||
170 | BEGIN;<br> | ||
171 | CREATE TABLE t2(a INTEGER, b INTEGER, c VARCHAR(100));<br> | ||
172 | INSERT INTO t2 VALUES(1,59672,'fifty nine thousand six hundred seventy two');<br> | ||
173 | <i>... 24997 lines omitted</i><br> | ||
174 | INSERT INTO t2 VALUES(24999,89569,'eighty nine thousand five hundred sixty nine');<br> | ||
175 | INSERT INTO t2 VALUES(25000,94666,'ninety four thousand six hundred sixty six');<br> | ||
176 | COMMIT;<br> | ||
177 | |||
178 | </blockquote><table border=0 cellpadding=0 cellspacing=0> | ||
179 | <tr><td>PostgreSQL:</td><td align="right"> 4.900</td></tr> | ||
180 | <tr><td>MySQL:</td><td align="right"> 2.184</td></tr> | ||
181 | <tr><td>SQLite 2.7.6:</td><td align="right"> 0.914</td></tr> | ||
182 | <tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 0.757</td></tr> | ||
183 | </table> | ||
184 | |||
185 | <p> | ||
186 | When all the INSERTs are put in a transaction, SQLite no longer has to | ||
187 | close and reopen the database or invalidate its cache between each statement. | ||
188 | It also does not | ||
189 | have to do any fsync()s until the very end. When unshackled in | ||
190 | this way, SQLite is much faster than either PostgreSQL and MySQL. | ||
191 | </p> | ||
192 | |||
193 | <h3>Test 3: 25000 INSERTs into an indexed table</h3> | ||
194 | <blockquote> | ||
195 | BEGIN;<br> | ||
196 | CREATE TABLE t3(a INTEGER, b INTEGER, c VARCHAR(100));<br> | ||
197 | CREATE INDEX i3 ON t3(c);<br> | ||
198 | <i>... 24998 lines omitted</i><br> | ||
199 | INSERT INTO t3 VALUES(24999,88509,'eighty eight thousand five hundred nine');<br> | ||
200 | INSERT INTO t3 VALUES(25000,84791,'eighty four thousand seven hundred ninety one');<br> | ||
201 | COMMIT;<br> | ||
202 | |||
203 | </blockquote><table border=0 cellpadding=0 cellspacing=0> | ||
204 | <tr><td>PostgreSQL:</td><td align="right"> 8.175</td></tr> | ||
205 | <tr><td>MySQL:</td><td align="right"> 3.197</td></tr> | ||
206 | <tr><td>SQLite 2.7.6:</td><td align="right"> 1.555</td></tr> | ||
207 | <tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 1.402</td></tr> | ||
208 | </table> | ||
209 | |||
210 | <p> | ||
211 | There were reports that SQLite did not perform as well on an indexed table. | ||
212 | This test was recently added to disprove those rumors. It is true that | ||
213 | SQLite is not as fast at creating new index entries as the other engines | ||
214 | (see Test 6 below) but its overall speed is still better. | ||
215 | </p> | ||
216 | |||
217 | <h3>Test 4: 100 SELECTs without an index</h3> | ||
218 | <blockquote> | ||
219 | BEGIN;<br> | ||
220 | SELECT count(*), avg(b) FROM t2 WHERE b>=0 AND b<1000;<br> | ||
221 | SELECT count(*), avg(b) FROM t2 WHERE b>=100 AND b<1100;<br> | ||
222 | <i>... 96 lines omitted</i><br> | ||
223 | SELECT count(*), avg(b) FROM t2 WHERE b>=9800 AND b<10800;<br> | ||
224 | SELECT count(*), avg(b) FROM t2 WHERE b>=9900 AND b<10900;<br> | ||
225 | COMMIT;<br> | ||
226 | |||
227 | </blockquote><table border=0 cellpadding=0 cellspacing=0> | ||
228 | <tr><td>PostgreSQL:</td><td align="right"> 3.629</td></tr> | ||
229 | <tr><td>MySQL:</td><td align="right"> 2.760</td></tr> | ||
230 | <tr><td>SQLite 2.7.6:</td><td align="right"> 2.494</td></tr> | ||
231 | <tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 2.526</td></tr> | ||
232 | </table> | ||
233 | |||
234 | |||
235 | <p> | ||
236 | This test does 100 queries on a 25000 entry table without an index, | ||
237 | thus requiring a full table scan. Prior versions of SQLite used to | ||
238 | be slower than PostgreSQL and MySQL on this test, but recent performance | ||
239 | enhancements have increased its speed so that it is now the fastest | ||
240 | of the group. | ||
241 | </p> | ||
242 | |||
243 | <h3>Test 5: 100 SELECTs on a string comparison</h3> | ||
244 | <blockquote> | ||
245 | BEGIN;<br> | ||
246 | SELECT count(*), avg(b) FROM t2 WHERE c LIKE '%one%';<br> | ||
247 | SELECT count(*), avg(b) FROM t2 WHERE c LIKE '%two%';<br> | ||
248 | <i>... 96 lines omitted</i><br> | ||
249 | SELECT count(*), avg(b) FROM t2 WHERE c LIKE '%ninety nine%';<br> | ||
250 | SELECT count(*), avg(b) FROM t2 WHERE c LIKE '%one hundred%';<br> | ||
251 | COMMIT;<br> | ||
252 | |||
253 | </blockquote><table border=0 cellpadding=0 cellspacing=0> | ||
254 | <tr><td>PostgreSQL:</td><td align="right"> 13.409</td></tr> | ||
255 | <tr><td>MySQL:</td><td align="right"> 4.640</td></tr> | ||
256 | <tr><td>SQLite 2.7.6:</td><td align="right"> 3.362</td></tr> | ||
257 | <tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 3.372</td></tr> | ||
258 | </table> | ||
259 | |||
260 | <p> | ||
261 | This test still does 100 full table scans but it uses | ||
262 | uses string comparisons instead of numerical comparisons. | ||
263 | SQLite is over three times faster than PostgreSQL here and about 30% | ||
264 | faster than MySQL. | ||
265 | </p> | ||
266 | |||
267 | <h3>Test 6: Creating an index</h3> | ||
268 | <blockquote> | ||
269 | CREATE INDEX i2a ON t2(a);<br>CREATE INDEX i2b ON t2(b); | ||
270 | </blockquote><table border=0 cellpadding=0 cellspacing=0> | ||
271 | <tr><td>PostgreSQL:</td><td align="right"> 0.381</td></tr> | ||
272 | <tr><td>MySQL:</td><td align="right"> 0.318</td></tr> | ||
273 | <tr><td>SQLite 2.7.6:</td><td align="right"> 0.777</td></tr> | ||
274 | <tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 0.659</td></tr> | ||
275 | </table> | ||
276 | |||
277 | <p> | ||
278 | SQLite is slower at creating new indices. This is not a huge problem | ||
279 | (since new indices are not created very often) but it is something that | ||
280 | is being worked on. Hopefully, future versions of SQLite will do better | ||
281 | here. | ||
282 | </p> | ||
283 | |||
284 | <h3>Test 7: 5000 SELECTs with an index</h3> | ||
285 | <blockquote> | ||
286 | SELECT count(*), avg(b) FROM t2 WHERE b>=0 AND b<100;<br> | ||
287 | SELECT count(*), avg(b) FROM t2 WHERE b>=100 AND b<200;<br> | ||
288 | SELECT count(*), avg(b) FROM t2 WHERE b>=200 AND b<300;<br> | ||
289 | <i>... 4994 lines omitted</i><br> | ||
290 | SELECT count(*), avg(b) FROM t2 WHERE b>=499700 AND b<499800;<br> | ||
291 | SELECT count(*), avg(b) FROM t2 WHERE b>=499800 AND b<499900;<br> | ||
292 | SELECT count(*), avg(b) FROM t2 WHERE b>=499900 AND b<500000;<br> | ||
293 | |||
294 | </blockquote><table border=0 cellpadding=0 cellspacing=0> | ||
295 | <tr><td>PostgreSQL:</td><td align="right"> 4.614</td></tr> | ||
296 | <tr><td>MySQL:</td><td align="right"> 1.270</td></tr> | ||
297 | <tr><td>SQLite 2.7.6:</td><td align="right"> 1.121</td></tr> | ||
298 | <tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 1.162</td></tr> | ||
299 | </table> | ||
300 | |||
301 | <p> | ||
302 | All three database engines run faster when they have indices to work with. | ||
303 | But SQLite is still the fastest. | ||
304 | </p> | ||
305 | |||
306 | <h3>Test 8: 1000 UPDATEs without an index</h3> | ||
307 | <blockquote> | ||
308 | BEGIN;<br> | ||
309 | UPDATE t1 SET b=b*2 WHERE a>=0 AND a<10;<br> | ||
310 | UPDATE t1 SET b=b*2 WHERE a>=10 AND a<20;<br> | ||
311 | <i>... 996 lines omitted</i><br> | ||
312 | UPDATE t1 SET b=b*2 WHERE a>=9980 AND a<9990;<br> | ||
313 | UPDATE t1 SET b=b*2 WHERE a>=9990 AND a<10000;<br> | ||
314 | COMMIT;<br> | ||
315 | |||
316 | </blockquote><table border=0 cellpadding=0 cellspacing=0> | ||
317 | <tr><td>PostgreSQL:</td><td align="right"> 1.739</td></tr> | ||
318 | <tr><td>MySQL:</td><td align="right"> 8.410</td></tr> | ||
319 | <tr><td>SQLite 2.7.6:</td><td align="right"> 0.637</td></tr> | ||
320 | <tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 0.638</td></tr> | ||
321 | </table> | ||
322 | |||
323 | <p> | ||
324 | For this particular UPDATE test, MySQL is consistently | ||
325 | five or ten times | ||
326 | slower than PostgreSQL and SQLite. I do not know why. MySQL is | ||
327 | normally a very fast engine. Perhaps this problem has been addressed | ||
328 | in later versions of MySQL. | ||
329 | </p> | ||
330 | |||
331 | <h3>Test 9: 25000 UPDATEs with an index</h3> | ||
332 | <blockquote> | ||
333 | BEGIN;<br> | ||
334 | UPDATE t2 SET b=468026 WHERE a=1;<br> | ||
335 | UPDATE t2 SET b=121928 WHERE a=2;<br> | ||
336 | <i>... 24996 lines omitted</i><br> | ||
337 | UPDATE t2 SET b=35065 WHERE a=24999;<br> | ||
338 | UPDATE t2 SET b=347393 WHERE a=25000;<br> | ||
339 | COMMIT;<br> | ||
340 | |||
341 | </blockquote><table border=0 cellpadding=0 cellspacing=0> | ||
342 | <tr><td>PostgreSQL:</td><td align="right"> 18.797</td></tr> | ||
343 | <tr><td>MySQL:</td><td align="right"> 8.134</td></tr> | ||
344 | <tr><td>SQLite 2.7.6:</td><td align="right"> 3.520</td></tr> | ||
345 | <tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 3.104</td></tr> | ||
346 | </table> | ||
347 | |||
348 | <p> | ||
349 | As recently as version 2.7.0, SQLite ran at about the same speed as | ||
350 | MySQL on this test. But recent optimizations to SQLite have more | ||
351 | than doubled speed of UPDATEs. | ||
352 | </p> | ||
353 | |||
354 | <h3>Test 10: 25000 text UPDATEs with an index</h3> | ||
355 | <blockquote> | ||
356 | BEGIN;<br> | ||
357 | UPDATE t2 SET c='one hundred forty eight thousand three hundred eighty two' WHERE a=1;<br> | ||
358 | UPDATE t2 SET c='three hundred sixty six thousand five hundred two' WHERE a=2;<br> | ||
359 | <i>... 24996 lines omitted</i><br> | ||
360 | UPDATE t2 SET c='three hundred eighty three thousand ninety nine' WHERE a=24999;<br> | ||
361 | UPDATE t2 SET c='two hundred fifty six thousand eight hundred thirty' WHERE a=25000;<br> | ||
362 | COMMIT;<br> | ||
363 | |||
364 | </blockquote><table border=0 cellpadding=0 cellspacing=0> | ||
365 | <tr><td>PostgreSQL:</td><td align="right"> 48.133</td></tr> | ||
366 | <tr><td>MySQL:</td><td align="right"> 6.982</td></tr> | ||
367 | <tr><td>SQLite 2.7.6:</td><td align="right"> 2.408</td></tr> | ||
368 | <tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 1.725</td></tr> | ||
369 | </table> | ||
370 | |||
371 | <p> | ||
372 | Here again, version 2.7.0 of SQLite used to run at about the same speed | ||
373 | as MySQL. But now version 2.7.6 is over two times faster than MySQL and | ||
374 | over twenty times faster than PostgreSQL. | ||
375 | </p> | ||
376 | |||
377 | <p> | ||
378 | In fairness to PostgreSQL, it started thrashing on this test. A | ||
379 | knowledgeable administrator might be able to get PostgreSQL to run a lot | ||
380 | faster here by tweaking and tuning the server a little. | ||
381 | </p> | ||
382 | |||
383 | <h3>Test 11: INSERTs from a SELECT</h3> | ||
384 | <blockquote> | ||
385 | BEGIN;<br>INSERT INTO t1 SELECT b,a,c FROM t2;<br>INSERT INTO t2 SELECT b,a,c FROM t1;<br>COMMIT; | ||
386 | </blockquote><table border=0 cellpadding=0 cellspacing=0> | ||
387 | <tr><td>PostgreSQL:</td><td align="right"> 61.364</td></tr> | ||
388 | <tr><td>MySQL:</td><td align="right"> 1.537</td></tr> | ||
389 | <tr><td>SQLite 2.7.6:</td><td align="right"> 2.787</td></tr> | ||
390 | <tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 1.599</td></tr> | ||
391 | </table> | ||
392 | |||
393 | <p> | ||
394 | The asynchronous SQLite is just a shade slower than MySQL on this test. | ||
395 | (MySQL seems to be especially adept at INSERT...SELECT statements.) | ||
396 | The PostgreSQL engine is still thrashing - most of the 61 seconds it used | ||
397 | were spent waiting on disk I/O. | ||
398 | </p> | ||
399 | |||
400 | <h3>Test 12: DELETE without an index</h3> | ||
401 | <blockquote> | ||
402 | DELETE FROM t2 WHERE c LIKE '%fifty%'; | ||
403 | </blockquote><table border=0 cellpadding=0 cellspacing=0> | ||
404 | <tr><td>PostgreSQL:</td><td align="right"> 1.509</td></tr> | ||
405 | <tr><td>MySQL:</td><td align="right"> 0.975</td></tr> | ||
406 | <tr><td>SQLite 2.7.6:</td><td align="right"> 4.004</td></tr> | ||
407 | <tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 0.560</td></tr> | ||
408 | </table> | ||
409 | |||
410 | <p> | ||
411 | The synchronous version of SQLite is the slowest of the group in this test, | ||
412 | but the asynchronous version is the fastest. | ||
413 | The difference is the extra time needed to execute fsync(). | ||
414 | </p> | ||
415 | |||
416 | <h3>Test 13: DELETE with an index</h3> | ||
417 | <blockquote> | ||
418 | DELETE FROM t2 WHERE a>10 AND a<20000; | ||
419 | </blockquote><table border=0 cellpadding=0 cellspacing=0> | ||
420 | <tr><td>PostgreSQL:</td><td align="right"> 1.316</td></tr> | ||
421 | <tr><td>MySQL:</td><td align="right"> 2.262</td></tr> | ||
422 | <tr><td>SQLite 2.7.6:</td><td align="right"> 2.068</td></tr> | ||
423 | <tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 0.752</td></tr> | ||
424 | </table> | ||
425 | |||
426 | <p> | ||
427 | This test is significant because it is one of the few where | ||
428 | PostgreSQL is faster than MySQL. The asynchronous SQLite is, | ||
429 | however, faster then both the other two. | ||
430 | </p> | ||
431 | |||
432 | <h3>Test 14: A big INSERT after a big DELETE</h3> | ||
433 | <blockquote> | ||
434 | INSERT INTO t2 SELECT * FROM t1; | ||
435 | </blockquote><table border=0 cellpadding=0 cellspacing=0> | ||
436 | <tr><td>PostgreSQL:</td><td align="right"> 13.168</td></tr> | ||
437 | <tr><td>MySQL:</td><td align="right"> 1.815</td></tr> | ||
438 | <tr><td>SQLite 2.7.6:</td><td align="right"> 3.210</td></tr> | ||
439 | <tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 1.485</td></tr> | ||
440 | </table> | ||
441 | |||
442 | <p> | ||
443 | Some older versions of SQLite (prior to version 2.4.0) | ||
444 | would show decreasing performance after a | ||
445 | sequence of DELETEs followed by new INSERTs. As this test shows, the | ||
446 | problem has now been resolved. | ||
447 | </p> | ||
448 | |||
449 | <h3>Test 15: A big DELETE followed by many small INSERTs</h3> | ||
450 | <blockquote> | ||
451 | BEGIN;<br> | ||
452 | DELETE FROM t1;<br> | ||
453 | INSERT INTO t1 VALUES(1,10719,'ten thousand seven hundred nineteen');<br> | ||
454 | <i>... 11997 lines omitted</i><br> | ||
455 | INSERT INTO t1 VALUES(11999,72836,'seventy two thousand eight hundred thirty six');<br> | ||
456 | INSERT INTO t1 VALUES(12000,64231,'sixty four thousand two hundred thirty one');<br> | ||
457 | COMMIT;<br> | ||
458 | |||
459 | </blockquote><table border=0 cellpadding=0 cellspacing=0> | ||
460 | <tr><td>PostgreSQL:</td><td align="right"> 4.556</td></tr> | ||
461 | <tr><td>MySQL:</td><td align="right"> 1.704</td></tr> | ||
462 | <tr><td>SQLite 2.7.6:</td><td align="right"> 0.618</td></tr> | ||
463 | <tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 0.406</td></tr> | ||
464 | </table> | ||
465 | |||
466 | <p> | ||
467 | SQLite is very good at doing INSERTs within a transaction, which probably | ||
468 | explains why it is so much faster than the other databases at this test. | ||
469 | </p> | ||
470 | |||
471 | <h3>Test 16: DROP TABLE</h3> | ||
472 | <blockquote> | ||
473 | DROP TABLE t1;<br>DROP TABLE t2;<br>DROP TABLE t3; | ||
474 | </blockquote><table border=0 cellpadding=0 cellspacing=0> | ||
475 | <tr><td>PostgreSQL:</td><td align="right"> 0.135</td></tr> | ||
476 | <tr><td>MySQL:</td><td align="right"> 0.015</td></tr> | ||
477 | <tr><td>SQLite 2.7.6:</td><td align="right"> 0.939</td></tr> | ||
478 | <tr><td>SQLite 2.7.6 (nosync):</td><td align="right"> 0.254</td></tr> | ||
479 | </table> | ||
480 | |||
481 | <p> | ||
482 | SQLite is slower than the other databases when it comes to dropping tables. | ||
483 | This probably is because when SQLite drops a table, it has to go through and | ||
484 | erase the records in the database file that deal with that table. MySQL and | ||
485 | PostgreSQL, on the other hand, use separate files to represent each table | ||
486 | so they can drop a table simply by deleting a file, which is much faster. | ||
487 | </p> | ||
488 | |||
489 | <p> | ||
490 | On the other hand, dropping tables is not a very common operation | ||
491 | so if SQLite takes a little longer, that is not seen as a big problem. | ||
492 | </p> | ||
493 | |||
494 | } | ||
495 | footer $rcsid | ||