Simon Slavin-3 wrote >> Thanks to your post I discovered multiple-row inserts so that I now >> understand what you asked. > > Just a note that multiple-row inserts were added to SQLite relatively > recently (2012-03-20 (3.7.11)) and, because SQLite does only > database-level locking, its overhead for INSERTs is far less than that of > SQL Server. It might be faster to use them but I would expect it to be so > much faster than many inserts as part of one transaction.
I made a fast, perhaps oversimplified, TestA: Create an empty database. (file based) CREATE TABLE Test (city NVARCHAR(120) NULL COLLATE NOCASE) BEGIN Then I inserted N records using commands such as INSERT INTO Test VALUES('_random_'). (_random was a random 8 character long string.) COMMIT Measure WAL size Close the DB Measure DB size TestB was performed with the same data except the records were grouped INSERT INTO Test VALUES('_random_'), VALUES('_random1')... I tested different groupings (1,2,5,10) and different N values (100000 - 2500000). Results: - The more records are grouped, the faster. - Grouping of 10 records was more than 2x faster than no grouping at all. - WAL size did not depend on the grouping used and was just slightly larger than the DB size. Then I modified the test by adding an index on the single column. I run 2 sets of tests - one where the index was created before first insert and the one with the index created after all inserts finished. Results: - Active index: WAL size ~ DB size - Inactive index: WAL size ~ 50% of the DB size - Tests with an active index were slower by 15-20% Conclusion: Switching off the indexing during a bulk insert brings minor advantages. Multi-row inserts may bring larger advantages. The reason of the "huge WAL problem" remains unclear. Note: The tests were programmed in c# code that called native SQLite.dll and were run on a W7 desktop. The results may not apply to other environments. -- View this message in context: http://sqlite.1065341.n5.nabble.com/Huge-WAL-log-tp79991p80070.html Sent from the SQLite mailing list archive at Nabble.com. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users