On 27 Mar 2013, at 9:55pm, Jeff Archer <jsarc...@nanotronicsimaging.com> wrote:

> Which is why I expected journal_mode = off to make it faster.  But it
> is 3 seconds faster when I leave journaling enabled and do all writes
> within a single transaction.

>> When I set journal_mode = off, same operation takes 5.5 seconds.
>> If I do all 5764 inserts within a single transaction only 2.5 seconds.

Reasonable figures.  With 5764 writes to the disk in separates transactions you 
have quite a lot of reading of data plus 5764 attempts to update the database 
file.  The updates have to be done in the right order, and each update has to 
wait for the disk to be rotated into the right position, though each update 
changes only a small amount of data (probably two sectors).

With 5764 writes to the disk in the same transaction, you have the same amount 
of reading needed, but only 1 attempt to write to the database file.  Although 
all the same sectors need writing, each one needs writing once only and the 
sectors can be written in any order (your drivers will probably optimize the 
order or writes they happen in whatever order will be fastest).

So yes, you save more time by doing your updates in one transaction than doing 
them separately.  In fact I'd thought that your figures would be further apart 
than 55%.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to