SQLite inserts slow

Ernesto Revilla <[email protected]> Wed, 23 Jun 2004 00:08:28 +0200
Newsgroups gmane.comp.python.modeling
Message-ID <[email protected]>
Dear Sébastien and everybody else:

I found SQLite inserts a bit slow. When enabling logging, I found that 
new keys are retrieved using the following SQL statement:

Transaction: BEGIN
Evaluating: UPDATE PK_SEQ_ROOM SET id=((select max(id) from PK_SEQ_ROOM)+1)
Evaluating: select id FROM PK_SEQ_ROOM
Transaction: COMMIT

Then, after checking the table definition I saw that  PK_SEQ_ROOM has 
just the id field, and as I read anywhere below, just one row, so the 
subquery should not be needed, not?

(file SQLiteAdaptorChannel.py near line 82)

On the other hand, changing this does not make it much faster. at least 
with my box, committing on each update and read for new primary keys is 
a bit slow, but for this delay sqlite has to be blamed.

Interesting enough that the following instruction makes it much faster 
causing SQLite to turn off disk sync:
*PRAGMA default_synchronous = OFF;

*
With best regards,
Erny