On Tue, Mar 15, 2011 at 12:52:42PM +0000, Philip Martin wrote: > Yes, by the time we invoke the callbacks we have a read-lock. If we > simply ran a single transaction and made callbacks within the > transaction then it would have the same effect. I don't see what the > temporary table achieves.
The temp tables live in a separate database. Without them, lock contention is on a single database. With them, the contention situation is different -- the callback cannot read from or write to the temp table. At least that is how I understand this text: http://sqlite.org/lang_createtable.html: If the "TEMP" or "TEMPORARY" keyword occurs between the "CREATE" and "TABLE" then the new table is created in the temp database. It is an error to specify both a <database-name> and the TEMP or TEMPORARY keyword, unless the <database-name> is "temp". If no database name is specified and the TEMP keyword is not present then the table is created in the main database. So we use the temp table to create a separate database that contains the data we need to present to the callback, and which is unaffected by whatever else the callback might be doing. Does that make sense?